Posted on 2022-11-18 16:55
Uriel 阅读(49)
评论(0) 编辑 收藏 引用 所属分类:
闲来无事重切Leet Code 、
大水题
判断一个数的因数是否只有2,3,5,大水题
1 #263
2 #Runtime: 31 ms
3 #Memory Usage: 13.4 MB
4
5 class Solution(object):
6 def isUgly(self, n):
7 """
8 :type n: int
9 :rtype: bool
10 """
11 while n > 1 and (n % 2) == 0:
12 n /= 2
13 while n > 1 and (n % 3) == 0:
14 n /= 3
15 while n > 1 and (n % 5) == 0:
16 n /= 5
17 if n == 1:
18 return True
19 return False