Code Zone
Labels
BareMinimum
Done
FrequentlyAsked
RecentQuestions
Revise
Thursday, January 19, 2012
C Program to calculate factorial of a number
Iterative:
int
findFactorial(
int
num){
int
i,f=1;
for
(i=1;i<=num;i++)
f=f*i;
return
f;
}
Recursive:
fact(int n)
{
int fact;
if(n==1)
return(1);
else
fact = n * fact(n-1);
return(fact);
}
No comments:
Post a Comment
Newer Post
Older Post
Home
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment