class Solution:
"""
@param: n: An integer
@return: An integer, denote the number of trailing zeros in n!
"""
def trailingZeros(self, n):
# write your code here, try to do it without arithmetic operators.
res = 0
tp = 5
while n/tp>=1:
res = res + int(n/tp)
tp = tp * 5
return res
Python, LintCode, 2. 尾部的零
最新推荐文章于 2019-10-20 10:19:09 发布