update 263
This commit is contained in:
parent
63789678f7
commit
5461d2ffd7
16
leetcode/263.py
Normal file
16
leetcode/263.py
Normal file
@ -0,0 +1,16 @@
|
||||
# Ugly number
|
||||
# If positive number n has prime factors limited to 2, 3 and 5,
|
||||
# it's a ugly prime
|
||||
# -2^31 <= n <= 2^31 - 1
|
||||
|
||||
|
||||
class Solution:
|
||||
def isUgly(self, n: int) -> bool:
|
||||
if n <= 0:
|
||||
return False
|
||||
|
||||
for p in [2, 3, 5]:
|
||||
while n % p == 0:
|
||||
n = n // p
|
||||
|
||||
return n == 1
|
Loading…
x
Reference in New Issue
Block a user