Saiful's World
Saturday, January 21, 2012
Factorial upto 19!
#include<stdio.h>
long long fact(int n)
{
int i;
long long result = 1;
for(i=n;i>1;i--)
result *= i;
return result;
}
int main()
{
int i,n;
while(scanf("%d",&n) == 1)
{
if(n == 0)printf("1\n");
else printf("%lld\n",fact(n));
}
return 0;
}
No comments:
Post a Comment
Newer Post
Older Post
Home
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment