This page looks best with JavaScript enabled

Leetcode 172 Factorial Trailing Zeroes

1
2
3
4
5
6
7
8
class Solution:
    def trailingZeroes(self, n: int) -> int:
        pw = 5
        cnt = 0
        while n >= pw:
            cnt += n // pw
            pw *= 5
        return cnt