Pl. Help me in solving factorial of any number in c languguage
factorial
Collapse
X
-
Originally posted by kpdhimanPl. Help me in solving factorial of any number in c languguage
n! = n*(n-1)*(n-2)*.....3*2*1
0!=1
1!=1
by convention.
To write a function which computes n! you could use recursion or a control structure, for/ while loop.
The structure of a function that computes the factorial might go as follows
Step 1: Error condition that eliminates the calculation of factorials of negative integers.
Step 2: Define the base cases 0!=1, 1!=1
Step 3: Implement the factorial algorithm as defined above.
Hope this has been of some help.Comment
Comment