Steward
分享是一種喜悅、更是一種幸福
程式語言 - LeetCode - C++ - 172. Factorial Trailing Zeroes
題目:

方法:
1. 尾數的 0 來自 => 2*5 => (2,5) => 所以要數的是 (2,5) 的配對數量 2. 公式:n/5 + n/(5*5) + n/(5*5*5) + ...
解答:
class Solution {
public:
int trailingZeroes(int n) {
int cnt = 0;
while (n > 0) {
n /= 5;
cnt += n;
}
return cnt;
}
};