【LeetCode】 172. Factorial Trailing Zeroes

来源:互联网 发布:cpu散片淘宝店家推荐? 编辑:程序博客网 时间:2024/06/07 09:03

Given an integer n, return the number of trailing zeroes in n!.

Note: Your solution should be in logarithmic time complexity.

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


0 0