calculating a factorial in this method :
unsigned long long factorial(int n){
unsigned long long temp = 1L;
for(int i = 0 ; i < n ; i++){
temp *=(n - i);
}
printf("\n%d factorial is %llu",n,temp);
return temp;
}
Allows calculation upto 20!
only.
20! = 2432902008176640000 << 2^64
21! = 51090942171709440000 >> 2^64
I'v never used uintmax_t
and reading from a few other SO articles , it all feels really complicated to use. If anyone could give some simple snippets as how to use and print them , it would be a major help.
Edit Regarding Didier Trosset's question , i thought that surely 20 wont be the limit upto which people can calculate a factorial in C. I was reading that uintmax_t is the biggest data type , so i thought it may be 128bits or something. So i wanted to use it.
Also , I didn't know about big int libraries in C. Sorry if i created a duplicate post.