home *** CD-ROM | disk | FTP | other *** search
/ Practical Programming in Tcl & Tk (4th Edition) / TCLBOOK4.BIN / pc / exsource.old / 1_14.tcl < prev    next >
Text File  |  2003-04-15  |  175b  |  15 lines

  1. #
  2. # Example 1-14
  3. # A recursive definition of factorial.
  4. #
  5.  
  6. proc Factorial {x} {
  7.     if {$x <= 1} {
  8.         return 1
  9.     } else {
  10.         return [expr {$x * [Factorial [expr {$x - 1}]]}]
  11.     }
  12. }
  13.  
  14.  
  15.