Saturday, June 14, 2008

Factorial

Function Factorial (n)

The above Function obtains the factorial of a given number n in a recursive manner. If the number is positive and other than zero then factorial is computed otherwise for zero the Function returns 1.


Step 1 If number is zero

if (n = 0) then

return 1.


Step 2 If number is greater than zero.

if (n > 0) then

return (n * Factorial (n – 1))

No comments: