class Solution {
/*
* param n: As desciption
* return: An integer, denote the number of trailing zeros in n!
*/
public long trailingZeros(long n) {
// 2015-09-09
// n的阶乘的因子中有几个5
// 因为2肯定比5多,所以不用考虑2
long rst = 0;
while ((n / 5) !=0) {
n /= 5;
rst += n;
}
return rst;
}
};
[刷题]Trailing Zeros
最新推荐文章于 2021-04-17 15:06:55 发布