Given an integer n, return the number of trailing zeroes in n!.
Note: Your solution should be in logarithmic time complexity.
//所有的因子里边含有2和5的个数,而2的个数明显会多余5的,所以只需要计算含有因子5为几个就是几个0,像25*4=100,所以25含有2个5(10含有一个2和一个5,)
public class Solution {
public int trailingZeroes(int n) {
int sum=0;
while(n>0){
sum+=n/5;
n=n/5;
}
return sum;
}
}