解题思路:
找阶乘后的零,本质上是找相乘的因子中5的个数,一般情况中,5的倍数中包含一个因子5,但是5的指数次方如25,就包含了2个因子5,这个要注意。
class Solution {
public:
int trailingZeroes(int n) {
// n = 10;
int ans = 0;
while(n) {
n /= 5;
ans += n;
}
return ans;
}
};