Simple Python Solution


  • 0
    P

    class Solution(object):
    def trailingZeroes(self, n):

        m = 0 
        res = 0 
        i = 1
        if n < 5:
            return 0
            
        while (m < n):
            m = pow(5,i)
            a,b = divmod(n,m)
            res += a
            i += 1
        return res

Log in to reply
 

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