class Solution:
def foo(self, num):
if num == 0:
return False
if num == 1:
return True
if num == 2:
return True
if num == 3:
return True
if num == 5:
return True
if num % 2 == 0:
return self.foo(num//2)
if num % 3 == 0:
return self.foo(num//3)
if num % 5 == 0:
return self.foo(num//5)
return False
def isUgly(self, n: int) -> bool:
return self.foo(n)