【leetcode】172.(Easy)Factorial Trailing Zeroes

(答案来自题目后面评论区)

提交代码:

class Solution {
    public int trailingZeroes(int n) {
        return n == 0 ? 0 : n / 5 + trailingZeroes(n / 5);
    }
}

运行结果:

【leetcode】172.(Easy)Factorial Trailing Zeroes_第1张图片

你可能感兴趣的:(leetcode)