Determine the number of trailing zeros in n! (n factorial). A trailing zero is produced by a factor of 10 = 2*5, and since factors of 5 are the scarcer, the count equals the number of times 5 divides n!.
One line: a non-negative integer n.
One line: the number of trailing zeros in n!.
Example 1
Input
5
Expected
1
Explanation
5! = 120 ends with one zero.
Example 2
Input
3
Expected
0
Explanation
3! = 6 has no trailing zero.
Ready to solve this?
Sign in to open the editor, run your code against the sample tests, and submit against the full test suite.
Sign in to solve →