Finding the k-th Hamming Number

Coding · Medium · Free problem
A positive integer is called a **Hamming number** (also known as a 3-smooth or ugly number) if its only prime factors are 2, 3, and 5. The sequence starts: 1, 2, 3, 4, 5, 6, 8, 9, 10, 12, 15, 16, ... Given a positive integer $k$, return the $k$-th Hamming number in ascending order. **Constraints:** -
\leq k \leq 1{,}690$ - The
{,}690$-th Hamming number fits in a 32-bit integer **Examples:** - Input: $k = 1$ -- Output:
$ (by convention, 1 is the first Hamming number) - Input: $k = 7$ -- Output: $8$ (the sequence is 1, 2, 3, 4, 5, 6, 8, so the 7th is 8) - Input: $k = 12$ -- Output:
6$ (the sequence is 1, 2, 3, 4, 5, 6, 8, 9, 10, 12, 15, 16)

Open the full interactive solver, hints, and worked solution →