Given an integer n, return the number of trailing zeroes in n!.
Note that n! = n * (n - 1) * (n - 2) * ... * 3 * 2 * 1.
Solution
Count How many 5 in the n
Code
- python
class Solution:
def trailingZeroes(self, n: int) -> int:
ret = 0
while n >= 5:
n //= 5
ret += n
return ret