+ 1

Is there a method to find large factorials having values larger than long long int also?

Is it possible to reach that limits using C language. Example: Is it possible to calculate 100! using C

18th Nov 2020, 12:55 PM
Gihan Kavinda
9 Answers
+ 4
You can use a logarithmic approximation or an arbitrary precision integer arithmetic https://stackoverflow.com/questions/1384160/calculating-factorial-of-large-numbers-in-c You can even handle it by yourself by storing big numbers splitted along an array rather than stored in a single variable. But I guess that's not easy.
18th Nov 2020, 1:15 PM
Davide
Davide - avatar
+ 2
If you need to face a really big number you might need to use a third party library or implement one yourself. unsigned long long can save up to 2^64-1, which is about 17 digits. Definitely not enough and not possible to save the number.
18th Nov 2020, 1:16 PM
äœ çŸ„é“èŠć‰‡ïŒŒæˆ‘äčŸæ˜Ż
äœ çŸ„é“èŠć‰‡ïŒŒæˆ‘äčŸæ˜Ż - avatar
+ 2
You can use gcc specific __uint128_t type which would allow you to calculate up to 34! Above that you need multiple precision arithmetics - either implementing your own, or using an existing library (for example gmp)
18th Nov 2020, 1:16 PM
Volodymyr Chelnokov
Volodymyr Chelnokov - avatar
18th Nov 2020, 9:36 PM
Mihai Apostol
Mihai Apostol - avatar
+ 1
This post might interest you: https://www.sololearn.com/post/88511/?ref=app
18th Nov 2020, 7:21 PM
Brian
Brian - avatar
+ 1
You can use "School's multiplication" method, I forgot the name exactly but you can try to look it up, I'm pretty sure you have a google search bar, I remember I've seen one on gfg.
19th Nov 2020, 11:00 PM
LastSecond959
LastSecond959 - avatar
+ 1
LastSecond959 it is known as "russian peasant multiplication".
19th Nov 2020, 11:08 PM
Brian
Brian - avatar
0
It will be error
18th Nov 2020, 1:13 PM
Synx_lights
Synx_lights - avatar