美文网首页
172. Factorial Trailing Zeroes

172. Factorial Trailing Zeroes

作者: 衣介书生 | 来源:发表于2018-04-08 20:55 被阅读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);
        }
    }
    

    相关文章

      网友评论

          本文标题:172. Factorial Trailing Zeroes

          本文链接:https://www.haomeiwen.com/subject/kzgmhftx.html