Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
using this precondition "Given int is below or equal of 1500". And I made the code simple. solution in Clear category for Ugly Numbers by tamagoyaki
def ugly_number(n: int) -> int:
arr = []
for i in range(30):
for i2 in range(25):
for i3 in range(20):
arr.append((i,i2,i3))
arr = sorted([2**i*3**i2*5**i3 for i,i2,i3 in arr])
return arr[n-1]
if __name__ == "__main__":
print("Example:")
print(ugly_number(4))
# These "asserts" are used for self-checking and not for an auto-testing
assert ugly_number(4) == 4
assert ugly_number(6) == 6
assert ugly_number(11) == 15
print("Ugly Numbers coding complete? Click 'Check' to earn cool rewards!")
Oct. 10, 2023
Comments: