题解 | #阶乘末尾0的数量#
阶乘末尾0的数量
http://www.nowcoder.com/practice/aa03dff18376454c9d2e359163bf44b8
class Solution {
public:
/**
* the number of 0
* @param n long长整型 the number
* @return long长整型
*/
long long thenumberof0(long long n) {
// write code here
long long res = 0;
long long d = 5;
// 看有多少个5的倍数
while(d <= n) {
res += n / d;
d *= 5;
}
return res;
}
};