Thinking process

find the pattern

  • why there is a 0? 2 * 5

Mistakes

  • 25 has two 5
public class Solution {
    public int trailingZeroes(int n) {
        int res = 0;
        while (n >= 5) {
            res += n / 5;
            n /= 5;
        }

        return res;
    }
}

results matching ""

    No results matching ""