This one is a bit mathy by nature. The goal is to find the number of trailing zeroes in X!. 5! = 120 so it has 1 trailing zero. Can you solve for 100!? If you choose to not go the programmatic route, what's the mathematical proof for this problem?
Update: The solution for Three Primes has been posted to the comments.
Comments:
David - 9 years, 9 months ago
You get an excess of factors of 2 relative to adding factors of 5, so every multiple of 5 will add a trailing zero. Additionally, every multiple of 25 will add an additional trailing zero. Based on this, one can simply count the multiples of 5 and 25 in [1,100]. For larger values of X, one must count multiples of each subsequent exponent of 5 less than X.
For 100! you get:
From wolframalpha you can count that there are in fact 24 zeroes.
reply permalink