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

Example 1:


Input: 3
Output: 0
Explanation: 3! = 6, no trailing zero.

Example 2:


Input: 5
Output: 1
Explanation: 5! = 120, one trailing zero.

Note: Your solution should be in logarithmic time complexity.

Difficulty: introductory

Starter code:

class Solution:
    def trailingZeroes(self, n: int) -> int:
        

Solutions:
class Solution:
     def trailingZeroes(self, n):
         """
         :type n: int
         :rtype: int
         """
         n_fives = 0
         while n > 0:
             n = n // 5
             n_fives += n
         return n_fives

class Solution:
     def trailingZeroes(self, n):
         """
         :type n: int
         :rtype: int
         """
         c=0
         while n>0:
             n//=5
             c+=n
         return c


class Solution:
     def trailingZeroes(self, n):
         """
         :type n: int
         :rtype: int
         """
         count = 1
         a = 5
         ans = 0
         
         while a<=n:
             ans += n//a
             count += 1
             a = 5**count
             
         return ans


class Solution:
     def trailingZeroes(self, n):
         """
         :type n: int
         :rtype: int
         """
         return 0 if n == 0 else n // 5 + self.trailingZeroes(n // 5)

class Solution:
     def trailingZeroes(self, n):
         """
         :type n: int
         :rtype: int
         """
         count = 0
         
         while n:
             count = count + n // 5
             n = n // 5
         return count
             
                 


class Solution:
     def trailingZeroes(self, n):
         two = 0
         five = 0
         tmp = n
         while tmp != 0:
             tmp = tmp//5
             five = five + tmp
         tmp = n
         while tmp != 0:
             tmp = tmp//2
             two = two + tmp
         res = min(five,two)
         return res
         """
         :type n: int
         :rtype: int
         """


class Solution:
     def trailingZeroes(self, n):
         """
         :type n: int
         :rtype: int
         """
         count = 0
         while n > 0:
             n /= 5
             count += int(n)
         return int(count)

class Solution:
     def trailingZeroes(self, n):
         """
         :type n: int
         :rtype: int
         """
         ans=0
         i=5
         while n//i:
             ans+=n//i
             i*=5
         return ans        

class Solution:
     def trailingZeroes(self, n):
         """
         :type n: int
         :rtype: int
         """
         return sum([n//5**i for i in range(1, 20)])

class Solution:
     def trailingZeroes(self, n):
         res = 5
         ans = 0
         while res < n+1:
             ans += int(n/res)
             res = 5*res
         return ans

class Solution:
     def trailingZeroes(self, n):
         """
         :type n: int
         :rtype: int
         """
         trz = 0
         div = 5
         while div <= n:
             trz += int(n / div)
             div *= 5
         return trz;
         #return 0 if n is 0 else n / 5 + self.trailingZeros(n / 5)


class Solution:
     def trailingZeroes(self, n):
         """
         :type n: int
         :rtype: int
         """
         if n < 5:
             return 0
         elif n < 10:
             return 1
 
         i = 0
         while 5 ** (i + 1) <= n:
             i += 1
 
         s=n//5
         j=2
         while j<=i:
             s+=n//(5**j)
             j+=1
 
 
         return int(s)

class Solution:
     def trailingZeroes(self, n):
         return n//5 + self.trailingZeroes(n//5) if n>=5 else 0


class Solution:
     def trailingZeroes(self, n):
         """
         :type n: int
         :rtype: int
         """
         res = 0
         while n >= 5:
             res = res + int(n/5)
             n = n/5
         return res


class Solution:
     def trailingZeroes(self, n):
         """
         :type n: int
         :rtype: int
         """
         
         num2 = 0
         div = 2
         quot = n // div
         while quot:
             num2 += quot
             div *= 2
             quot = n // div
         
         num5 = 0
         div = 5
         quot = n // div
         while quot:
             num5 += quot
             div *= 5
             quot = n // div
             
         return min(num2, num5)

class Solution:
     def trailingZeroes(self, n):
         """
         :type n: int
         :rtype: int
         """
         return 0 if n == 0 else n//5 + self.trailingZeroes(n // 5)