@coffeeaddict8 I modified your solution. And it looks a little simpler and runs a bit faster.

```
def isUgly(self, num):
if not num:
return False
else:
while not num % 5: num /= 5
while not num % 3: num /= 3
while not num % 2: num /= 2
return num == 1
```

## Using the following script, you can compare the speed of the two code.

```
from timeit import timeit
r,n = xrange(1000000),10
class Solution(object):
def isUgly1(self, num):
while num % 2 == 0 and num!=0:
num = num/2
while num % 3 == 0 and num!=0:
num = num/3
while num % 5 == 0 and num!=0:
num = num/5
if num != 1:
return False
return True
def isUgly2(self, num):
if not num:
return False
else:
while not num % 5: num /= 5
while not num % 3: num /= 3
while not num % 2: num /= 2
return num == 1
print timeit(lambda: map(Solution().isUgly1, r), number=n)
print timeit(lambda: map(Solution().isUgly2, r), number=n)
```