题解 | #阶乘末尾0的数量#
阶乘末尾0的数量
https://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 result = 0;
long long temp = 5;
while (n >= temp) {
result += n / temp;
temp = temp * 5;
}
return result;
}
};
查看9道真题和解析