0

How to calculate factorial of any large value as 100 or 100+ and how to print it in C language

which data type is used in C for print or store long integers which has more than 150 digits

19th Aug 2018, 11:19 AM
Ankit Verma
Ankit Verma - avatar
3 Answers
19th Aug 2018, 12:24 PM
blACk sh4d0w
blACk sh4d0w - avatar
+ 2
You can use floating-point types (long double would be your best bet) to get an approximation, but if you want to get every digit you need to implement arbitrary length integers yourself (allocate memory, ake functions to add them together, etc.). Fortunately people have already written the necessary code. Take a look at gmplib.
19th Aug 2018, 11:31 AM
Vlad Serbu
Vlad Serbu - avatar
+ 2
Ankit Verma you should use string data type to handle these and write your own algorithm to multiply digits of string
19th Aug 2018, 3:41 PM
Ketan Lalcheta
Ketan Lalcheta - avatar