LeetCode 172 _ 阶乘后的零

1. 题目描述

2. 代码

1 class Solution:
2     def trailingZeroes(self, n: int) -> int:
3         count = 0
4         while (n > 0):
5             count += n // 5
6             n = n // 5
7         return count

思路: 计算n中因子5的个数, 返回count即可.

3. 整理

// , 取整除 - 向下取接近商的整数

1 9//2
2 
3 2
9//5

1
原文地址:https://www.cnblogs.com/vvzhang/p/13842246.html