- 从底向上,一次计算,其实是属于增量式计算因子5的数量
class Solution {
public:
/**
* the number of 0
* @param n long长整型 the number
* @return long长整型
*/
long long thenumberof0(long long n) {
// write code here
if(n<=4){
return 0;
}
long long res = 0;
long long divisor = 5;
while(divisor<=n){
res += n/divisor;
divisor *= 5;
}
return res;
}
};
京公网安备 11010502036488号