Click here to Skip to main content
15,889,992 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello friends,
I have a problem. I want to find factorial of big numbers.
Ex: 1555! = ?.
195! = ?.
My main problem is that I want to know the exact number of ending 0's of the factorial numbers.

I use the following formula:
(m!)^n = m! = 2*10^(n-1) + 2^2 * 10^(n-2) + ------- + 2^n.

with this I can solve the other factorials for number of ending 0's like this.

100!= 2*10^1 + 2^2*10^0 = 20+4 = 24
100! has 24 ending 0's as per this calculation.

But, then I got other problem,
Ex: For 95!
i) 95! = (100 - 5)! = 24 - 2*5^(1-1) = 24 - 2 = 22 => 95! has 22 0's.

ii) 95! = (90 + 5)! = 9*(2*10^0) + 2*5^0)= 18+2 = 20 => 95! has 20 0's.

this is my problem. By using the above formula I got two different answers and I am confused, I don't get the perfect answer so please help me to find it.

Thank you...
Posted
Updated 7-Feb-13 22:35pm
v2

1 solution

In C, this is not so easy. And I don't know good available library; maybe someone else will point out one for you. You can find some ideas here: http://stackoverflow.com/questions/3340511/what-is-the-simplest-way-of-implementing-bigint-in-c[^].

—SA
 
Share this answer
 
Comments
VISH_a_CODE 7-Feb-13 2:06am    
Thanks Sir, I am trying your hint... :)
Sergey Alexandrovich Kryukov 7-Feb-13 8:40am    
You are very welcome.
Good luck, call again.
—SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900