Description
An ugly number is a positive integer whose prime factors are limited to 2, 3, and 5. Return the nth ugly number.
Examples
Input:
n = 10Output:
12Explanation:
1,2,3,4,5,6,8,9,10,12 are the first 10 ugly numbers.
Input:
n = 1Output:
1Explanation:
Additional test case for verification.
Input:
n = 15Output:
24Explanation:
The first 15 ugly numbers are: 1, 2, 3, 4, 5, 6, 8, 9, 10, 12, 15, 16, 18, 20, 24. Each number's prime factors contain only 2, 3, and/or 5. For example, 24 = 2³ × 3¹, so it qualifies as an ugly number.
Constraints
- •
1 ≤ n ≤ 1690