Skip to content

Instantly share code, notes, and snippets.

@manuj10
Created August 24, 2012 11:21
Show Gist options
  • Save manuj10/3449367 to your computer and use it in GitHub Desktop.
Save manuj10/3449367 to your computer and use it in GitHub Desktop.
computing factorial of a larger no
#include<stdio.h>
#include<stdlib.h>
int main()
{int pdt,rem=0,count,no;
long int x=0;
long int res[60000];
long register int i;
printf("enter the number whose factorial has to be calculated");
scanf("%d",&no);
for(i=0;i<60000;i++)
res[i]=0;
res[59999]=1;
i=i-1;
for(count=2;count<=no;count++)
{while(i>0)
{pdt=res[i]*count+rem;
rem=0;
if(pdt>9)
{res[i]=pdt%10;
rem=pdt/10;
}
else
{res[i]=pdt;
}
i--;
}
rem=0;
pdt=0;
i=59999;
}
printf("factorial is\n");
for(i=0;i<=59999;i++)
{if(res[i]!=0||count==1)
{printf("%d",res[i]);
count=1;
x++;
}}
printf("%d",x);
return(0);}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment