题解 | #阶乘末尾0的数量#
阶乘末尾0的数量
http://www.nowcoder.com/practice/aa03dff18376454c9d2e359163bf44b8
public class Solution {
/**
* the number of 0
* @param n long长整型 the number
* @return long长整型
*/
public long thenumberof0 (long n) {
// write code here
long count = 0;
long d = 5;
while(n >= d){
count+=n/d;
n = n/d;
}
return count;
}
}
该题就是判断有几个0,阶乘中有多少个10就有多少个0;所以判读一个数有几个5就可以知道。