原题网址:https://leetcode.com/problems/factorial-trailing-zeroes/
Given an integer n, return the number of trailing zeroes in n!.
Note: Your solution should be in logarithmic time complexity.
方法:0的个数由5决定。
public class Solution {
public int trailingZeroes(int n) {
int zeros = 0;
for(long f=5; f<=n; f*=5) zeros += n/f;
return zeros;
}
}