问题描述:
Given an integer n, return the number of trailing zeroes inn!.
Note: Your solution should be in logarithmic time complexity.
基本思想
尾0的个数取决于5的个数。
代码:
int trailingZeroes(int n) { //C++
if(n <= 0)
return 0;
int num = 0;
int size;
while(n!=0){
size = n/5;
num += size;
n = size;
}
return num;
}