Python in 40ms

  • 0
    def trailingZeroes(self, n):
            :type n: int
            :rtype: int
            import math
            if n == 0:
                return 0
            res = 0
            x = (int)(math.log(n,5)) # Have 5^x inside
            for i in xrange(1,x+1):
                res += n/5**i
            return (int)(res)

Log in to reply

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.