An ugly number is a positive whole number whose only prime factors are 2, 3 and 5. The first ones are 1, 2, 3, 4, 5, 6, 8, 9, 10, 12, .... Return the n-th ugly number (n = 1 gives 1).
For n = 10 the answer is 12.
The starter code tests every whole number in turn. It is correct but too slow when n is large.
Example 1
Input:
nth_ugly_number(10)
Output:
12
Example 2
Input:
nth_ugly_number(1)
Output:
1
1 <= n <= 100000No results yet
Run your code to check it against the examples, or submit to run every test.