Factorial Trailing Zeroes
Given an integer n, return the number of trailing zeroes in n!.
Note: Your solution should be in logarithmic time complexity.
代码:
int trailingZeroes(int n) {
if(n == 0)
return 0;
int result = 0;
for (long long i = 5; n/i > 0; i *= 5)
result += n/i;
return result;
}
原题地址:https://leetcode.com/problems/factorial-trailing-zeroes/