Compute Factorial of Large Numbers using C

int main()
{
int a[200],n,counter,temp,i;
a[0]=1;
counter=0;
printf(“Enter the number to Find Factorial: “);
scanf(“%d”,&n);
for(; n>=2; n–)
{
temp=0;
for(i=0; i<=counter; i++) { temp=(a[i]*n)+temp; a[i]=temp%10; temp=temp/10; } while(temp>0)
{
a[++counter]=temp%10;
temp=temp/10;
}
}
for(i=counter; i>=0; i–)
printf(“%d”,a[i]);
return 0;
}
OUTPUT:

Enter the number to Find Factorial: 100
93326215443944152681699238856266700490715968264381621468592963895217599993229915
608941463976156518286253697920827223758251185210916864000000000000000000000000

Leave a Reply

Your email address will not be published. Required fields are marked *