172. Factorial Trailing Zeroes

2018-04-08  本文已影响1人  衣介书生

题目分析

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);
    }
}
上一篇 下一篇

猜你喜欢

热点阅读