dsa · easy
Factorial Trailing Zeroes
Return how many trailing zeros n! has in decimal. Do not compute n! as a giant integer — count the factors of ten, which come from pairs of 2 and 5 in the prime factorization (5s are the scarce ones).
Arguments
n— non-negative integer; return the trailing-zero count of n!
Example
n = 5: 5! = 120 ends with one zero → 1.
n = 0: 0! = 1 has no trailing zero → 0.
n = 10: 10! = 3,628,800 → 2.
Constraints
0 <= n <= 4*10^4 Hidden tests include near-max size for this bound; a slower-than-intended solution TLEs.
Examples
Example 1
Input: 5 Expected: 1
Example 2
Input: 0 Expected: 0
Example 3
Input: 10 Expected: 2