17.09. Get Kth Magic Number
Description
Design an algorithm to find the kth number such that the only prime factors are 3, 5, and 7. Note that 3, 5, and 7 do not have to be factors, but it should not have any other prime factors. For example, the first several multiples would be (in order) 1, 3, 5, 7, 9, 15, 21.
Example 1:
Input: k = 5 Output: 9
Solutions
Solution 1
1 2 3 4 5 6 7 8 9 10 11 |
|