-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path172.py
41 lines (37 loc) · 783 Bytes
/
172.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
class Solution(object):
def trailingZeroes(self, n):
"""
:type n: int
:rtype: int
"""
"""
ans = str(self.factorial(n))
i = len(ans) - 1
zeros = 0
while i >= 0:
if ans[i] == '0':
zeros += 1
i -= 1
else:
break
return zeros
"""
exp = 0
while 5 ** exp < n:
exp += 1
ans = 0
i = 1
while i <= exp:
ans += n / (5 ** i)
i += 1
return ans
"""
def factorial(self, n):
ans = 1
while n > 1:
ans *= n
n -= 1
return ans
"""
if __name__ == '__main__':
solution = Solution()