C Program to find Factorial of Number



/* Factorial upto 19! */


#include<stdio.h>

long long fact(int n)
{
    int i;
    long long result = 1;
    clrscr();
    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));
    }
   getch();
}

Post a Comment

0 Comments