LeetCode #263: Ugly Number
• 38 words • 1 min • updated
python
class Solution:
def isUgly(self, n: int) -> bool:
if n <= 0:
return False
for factor in [2, 3, 5]:
while n % factor == 0:
n //= factor
return n == 1∎
Connections
Shared tags