A fast python solution, looking for the number of five


  • 1
    R
    class Solution(object):
        def trailingZeroes(self, n):
            results = 0
            ans = 1
            thePower = 0
            while ans >= 1:
                thePower += 1
                ans = n/(5**thePower)
                results += int(ans)
        return results

Log in to reply
 

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