Visitor No.

Sunday 13 December 2015

Recursive LISP function to compute factorial of a given number

4 - Define a Recursive LISP function to compute factorial of a given number.

  

    Implementation Code in LISP -
      
     (defun fact (x)
     (if (= x 1) 1 
     (* x (fact (- x 1)))))

   OUTPUT-

     (fact 5)
      120

No comments:

Post a Comment