I\'ve a very long factorial program which needs to find factorial up to 100. It works well up to 33 factorial but not from 34. Can someone help in identifying the problem.>
You are definitely overflowing, when I print out the carry
values that are added to the vector:
1
5
4
3
3
3
4
6
8
13
20
35
64
121
243
510
1124
2585
6204
15511
40329
108888
304888
884176
2652528
8222838
26313083
86833176
-134263930
-134263930-639604140847618609643520000000
I switched to long long
for the vector and for carry
and mul
and was able to get the correct answer for 34!, but 99! still overflows. Seems you need to further reduce the numbers you are adding to the vector.