Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for Ugly Numbers by tokiojapan55
def ugly_number(n: int) -> int:
from operator import mul
from functools import reduce
from itertools import combinations_with_replacement as combi
f, table = 1, {1}
while len([t for t in list(table) if t <= 2**f]) < n:
table |= {reduce(mul, a) for a in combi([2, 3, 5], f)}
f += 1
return sorted(table)[n - 1]
Dec. 9, 2021
Comments: