Factorial Trailing Zeroes
Return the number of trailing zeroes in n!.
Examples
Input: 3
Output: 0
Input: 5
Output: 1
Hints
Understand that trailing zeroes in n! are determined by the number of times n! can be divided by 10, which depends on pairs of factors 2 and 5.
Recognize that the number of 2s in n! is always greater than or equal to the number of 5s, so focus solely on counting the number of 5s in the prime factorization of n!.
Generalize the counting process by summing the integer divisions of n by increasing powers of 5 (5, 25, 125, ...) until the division result becomes zero.
Related Problems
Factorial Trailing Zeroes
Return the number of trailing zeroes in n!.