Given an integer n, return the number of trailing zeroes in n!.
Note: Your solution should be in logarithmic time complexity.
题意:求n的阶乘结果里会有多少个0
思路:这个问题跟5有关,找跟5有关的个数。
class Solution {
public:
int trailingZeroes(int n) {
int num = 0;
while (n){
int a = n / 5;
num += a;
n = a;
}
return num;
}
};