6 lines python code


  • 1
    R
    class Solution(object):
        def trailingZeroes(self, n):
            """
            :type n: int
            :rtype: int
            """
            i, count = 1, 0
            power = pow(5,i)
            while power <= n:
                count += n / power
                i += 1
                power = pow(5, i)
                
            return count
    

Log in to reply
 

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