I started dividing the number out by 5 first since it would reduce the number before dividing out by the smaller 3 and then 2.

```
class Solution(object):
def isUgly(self, num):
if num <= 0:
return False
while num % 5 == 0:
num /= 5
while num % 3 == 0:
num /= 3
while num % 2 == 0:
num /= 2
return num == 1
```