题目分析
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) {
return n / 5 == 0 ? 0 : n / 5 + trailingZeroes(n / 5);
}
}
网友评论