Difficulty : easy
Approach : 1) number range check 2) divide with [2, 3, 5] as much as possible
class Solution:
def isUgly(self, num: int) -> bool:
if num == 1:
return True
elif num <= 0:
return False
while not num % 5:
num //= 5
while not num % 3:
num //= 3
while not num % 2:
num //= 2
return num == 1