[LeetCode]172. Factorial Trailing Zeroes
题目描述
思路
实际上是求数的因子5的个数
代码
#include <iostream>
using namespace std;
class Solution {
public:
int trailingZeroes(int n) {
int res = 0;
while (n > 0) {
n /= 5;
res += n;
}
return res;
}
};
int main() {
Solution s;
cout << s.trailingZeroes(30) << endl;
system("pause");
return 0;
}