Factorial Trailing Zeroes
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 ret = 0;
while(n)
{
ret += n /= 5;
}
return ret;
}
};扩展思维:[LeetCode] Factorial Trailing Zeroe
原文:http://blog.csdn.net/kangrydotnet/article/details/44995811