Problem Summary
Find the number of trailing zeros in N! (N factorial).
Solution
Apparently, the answer is equal to the number of 5 in N!, e.g. N/5 + N/(5^2) + N/(5^3) + … + N/(5^c), where 5^c ≤ N < 5^(c+1).
Code
|
|
Find the number of trailing zeros in N! (N factorial).
Apparently, the answer is equal to the number of 5 in N!, e.g. N/5 + N/(5^2) + N/(5^3) + … + N/(5^c), where 5^c ≤ N < 5^(c+1).
|
|