update 263

This commit is contained in:
sangge-rockpi 2024-01-20 23:15:29 +08:00
parent 63789678f7
commit 5461d2ffd7

16
leetcode/263.py Normal file
View 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