题目:
Given an integer n, return the number of trailing zeroes in n!.
Note: Your solution should be in logarithmic time complexity.
解答:
class Solution {
public:
int trailingZeroes(int n) {
int i = 0;
while (n >= 5) {
i += n / 5;
n /= 5;
}
return i;
}
};
LeetCode——Factorial Trailing Zeroes
原文地址:http://blog.csdn.net/cshun1990/article/details/46507029