Rahul Kumar Saurabh

A Recursive LISP function to compute factorial of a given number.

          Programs in lisp with output


SOFTWARE USED:  LispWorks 6.1

THEORY:-
Factorial
The factorial of a non-negative integer n , denoted by n! , is the product of all positive integers less than or equal to n.


Example-
                       4! = 4 * 3 * 2 * 1 = 24
similarly         6! = 6 * 5 * 4 * 3 * 2 * 1 =  720
The value of 0! is 1, according to the convention for an empty product.

SOURCE CODE ( IF INCLUDED )
(defun factorial (n)
  
(if (= n 1)
 1
 (* n (factorial (- n 1)))))

(factorial 4)
24

(factorial 6)
720

RESULT:-



CONCLUSION:-
We learned about writing the function to compute factorial of a given number.