~cpp def divisor(target, div): if target < div: return target while target % div == 0: target /= div return target def isUgly(target): target = divisor(target, 2) target = divisor(target, 5) target = divisor(target, 3) if target != 1: return False return True n = 1 count = 1; while count != 1500: if isUgly(n): print n , count count+=1 n+=1 print n-1