Ugly Number II

Given an integer n, return the n-th ugly number. Ugly numbers are positive numbers whose prime factors are limited to 2, 3, and 5.

Input Format

n = position in the ugly number sequence

Output Format

the n-th ugly number

Constraints

  • 1 <= n <= 1690

Examples

Example 1:

Input:

n = 10

Output:

12

Explanation:

The first 10 ugly numbers end at 12.

Example 2:

Input:

n = 1

Output:

1

Explanation:

The first ugly number is 1.

Loading...
Ugly Number II - Math DSA Problem