programming-examples/python/Misc/Python program to check whether a given number is an ugly number.py
2019-11-15 12:59:38 +01:00

10 lines
240 B
Python

def is_ugly(num):
if num == 0:
return False
for i in [2, 3, 5]:
while num % i == 0:
num /= i
return num == 1
print(is_ugly(12))
print(is_ugly(13))