class Solution {
public:
int trailingZeroes(int n) {
int ans1=0;
while(n > 0){
ans1 += n/5;
n/=5;
}
return ans1;
}
};leetcode 172. Factorial Trailing Zeroes
最新推荐文章于 2025-12-06 07:43:37 发布
本文介绍了一种高效计算任意正整数阶乘后尾随0的数量的方法。通过不断除以5并累加的方式,实现了O(log n)的时间复杂度。
729

被折叠的 条评论
为什么被折叠?



