设计一个算法,计算出n阶乘中尾部零的个数
public long trailingZeros(long n) {
// write your code here, try to do it without arithmetic operators.
long count = 0;
long temp = n/5;
while(temp != 0){
count = count+temp;
temp = temp/5;
}
return count;
}
写完啦~可以吃饭了