home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / mutt / fact.mut < prev    next >
Text File  |  1988-03-01  |  330b  |  18 lines

  1. ; Factorial the recursive way
  2.  
  3. (defun
  4.   fact (int n) HIDDEN    ; the recursive part.  input: n  output: n!
  5.   {
  6.     (if (== n 0) 1        ; 0! = 1
  7.       (* n (fact (- n 1)))    ; n! = n * (n-1)!
  8.     )
  9.   }
  10.   !    ; the main routine
  11.   {
  12.     (int n)
  13.     (n (atoi (ask "Take factorial of: ")))
  14.     (msg n "! = " (fact n))
  15.   }
  16. )
  17. (!)
  18.