172.Factorial Trailing Zeroes

1-Think about why logarithmic

https://discuss.leetcode.com/topic/6848/my-explanation-of-the-log-n-solution

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

results matching ""

    No results matching ""