Given an integer n, return the number of trailing zeroes in n!.
Note: Your solution should be in logarithmic time complexity.
思路:實現很簡單,關鍵的分析題意,要求n!末尾的0數,事實上可以求5和2的對數。而又因爲出現5必定出現2,所以求5個數即可.
int trailingZeroes(int n) {
int count = 0;
n = n/5;
while(n>0)
{
count+=n;
n /=5;
}
return count;
}