题目:
给定一个整数 n ,返回 n! 结果中尾随零的数量。
提示 n! = n * (n - 1) * (n - 2) * … * 3 * 2 * 1
思路:
来源:https://leetcode-cn.com/problems/factorial-trailing-zeroes/solution/c-shu-xue-xiang-xi-tui-dao-by-zeroac/
解答通俗易懂,赞啊!
解答:
class Solution:
def trailingZeroes(self, n: int) -> int:
five=0
while n>=5:
n//=5
five+=n
return five