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 = 10
Output:12
Explanation:

1,2,3,4,5,6,8,9,10,12 are the first 10 ugly numbers.

Input:n = 1
Output:1
Explanation:

Additional test case for verification.

Input:n = 15
Output:24
Explanation:

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

Ready to solve this problem?

Practice solo or challenge other developers in a real-time coding battle!