+ 1
What to do for running the factorial for the number 100
when i enter short numbers such as 10 it gives right answer but when i insert 100 it gives us negative value https://code.sololearn.com/cubUgpUKWskX/?ref=app
3 Answers
+ 9
You may need a boost library
Check out this link:
https://www.boost.org/doc/libs/1_54_0/libs/multiprecision/doc/html/boost_multiprecision/tut/ints/egs/factorials.html
+ 3
You can use a bigger number type, for example 'unsigned long long' instead of 'int'. Then you can handle larger numbers; but not 100! - the numbers get too large very quickly.
What you can do: Write a program that calculates the number digit by digit and stores them in an array.
You can see an example in this code (although yours will be harder (and in this case they aren't stored but just couted)):
https://code.sololearn.com/cz7MX8k6RK0d/?ref=app
+ 2
Try float fact but the output will be in sientific notation and becomes to great to handle so that it gives inf for bigger nums what i think stands for infinity