`

Factorial Trailing Zeroes——Math

阅读更多

Given an integer n, return the number of trailing zeroes in n!.

Note: Your solution should be in logarithmic time complexity.

class Solution(object):
    def trailingZeroes(self, n):
        """
        :type n: int
        :rtype: int
        """
        result = 0
        t = 5
        while t <= n:
        	result += n/t
        	t *= 5
        return result

 

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics