I am trying to find the numbers till 100! (factorial) but after 20! it gives an error as the value is too large to handle. How can I store such a
This code will help up to 170!. Use double for the factorial function, because normal int or long int will not support that factorial result, double will support up to 1.7e308.
#include
double fact(int k){
int i;
double f=1;
for(i=1;i<=k;i++) f=f*i;
return (f);
}
int main(){
int i;
for(i=1;i<=65;i++)
printf("%d! = %.3lf\n",i,fact(i));
return 0;
}