Last active

Embed URL

HTTPS clone URL

SSH clone URL

You can clone with HTTPS or SSH.

Download Gist
View BigFactorial.c
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
/**
* Date: August-2013
* Comment: The program can find very big factorial result, and it can be changed by changing 'DIGIT' value.
**/
 
#include <stdio.h>
 
#define DIGIT 1000000 //change accordingly
 
int main()
{
while(1)
{
short int a[DIGIT+1];
int x, i;
for(i=0; i<DIGIT+1; i++) a[i]=-1;
 
printf("Enter your integer : ");
scanf("%d", &x);
if(x<1) break;
 
int j;
i=x;
for(j=DIGIT; i>0; j--)
{
a[j]=i%10;
i=i/10;
}
 
int k=0;
for(i=x-1; i>0; i--)
{
for(j=DIGIT; a[j]>=0; j--)
{
k=(i*a[j])+k;
a[j]=k%10;
k=k/10;
}
 
a[j]=k%10;
k=k/10;
a[j-1]=k;
 
for(k=0; a[k]<1; k++) a[k]=-1;
k=0;
}
 
 
for(i=0; a[i]<1; i++);
for(; i<DIGIT+1; i++) printf("%hd", a[i]);
printf("\n\n");
}
 
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.