地址:点击打开链接
n!后缀0的个数 = n!质因子中5的个数
= floor(n/5) + floor(n/25) + floor(n/125) + ....
根据公式解出来
class Solution(object):
def trailingZeroes(self, n):
"""
:type n: int
:rtype: int
"""
res = 0
x = 5
while n >= x:
res += n/x
x *= 5
return res