/*
Given an integer n, return the number of trailing zeroes in n!.
Note: Your solution should be in logarithmic time complexity.
n!中包含多少尾随的0
10=2*5 n!中包含的0的个数就是因子2、5的个数,在n!中 2的个数多于5的
个数,所以只要统计有多少个5即可。
eg: 125=5*5*5 有3个5
n/5 表示有多少个数含有5这个因子 ,但像125这个数含有多个因子,需要重复迭代,
即先求出n/5(含有5的数的个数) 后,n/=5 即除去每个数中的5(数中如果含有因子5,因子5的个数减一) 重复上述过程 直到n=0
*/
class Solution {
public:
int trailingZeroes(int n) {
int res=0;
for(int i=n/5;i>0;i=n/5){
n/=5;
res+=n;
}
return res;
}
};