Title: https://leetcode-cn.com/problems/factorial-trailing-zeroes/ The
essence is to find the number of 5 in n!
The way of thinking: first find the number with 1 and 5
, and then find the number with 2 5s
…
class Solution {
public:
int trailingZeroes(int n) {
int res = 0;
while(n) {
res += n/5;
n /= 5;
}
return res;
}
};