Given an integer n, return the number of trailing zeroes in n!. Note that n! = n * (n - 1) * (n - 2) * ... * 3 * 2 * 1.
Example 1
Input: n = 100
Output: 24
Explanation: Each trailing zero comes from a factor of 10 = 2 × 5, and factors of 5 are the rarer ones. 100! contains 100 / 5 = 20 multiples of 5, and 100 / 25 = 4 of them (25, 50, 75, 100) contribute a second 5. That gives 24 zeros.
Example 2
Input: n = 3
Output: 0
Explanation: 3! = 6, which has no trailing zeros.
Example 3
Input: n = 5
Output: 1
Explanation: 5! = 120, which has exactly one trailing zero.
A trailing zero comes from a factor of 10 = 2 x 5, and factors of 2 are far more plentiful than factors of 5. So the count of trailing zeroes equals the number of times 5 divides into n! — which is n/5 + n/25 + n/125 + ...
Run checks all cases above. Submit evaluates all test cases.