# Find the Nth number whose only prime factors are 2, 3, 5, and/or 7 (humble numbers) [duplicate]

First post here! I recently participated in a small friendly competition and this was one of the questions:

A positive integer whose only prime factors are 2, 3, 5 or 7 is called a humble number.

The first 20 humble numbers are:

1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 12, 14, 15, 16, 18, 20, 21, 24, 25, 27


Write a program of function that when given a positive integer N, prints or returns the Nth humble number.

Examples

1 -> 1
11 -> 12
22 -> 30


This is so the shortest answer in bytes wins. I'm interested in seeing solutions that run in O(N) but this is not a requirement.

• @Calvin'sHobbies: I thought that too, but the very last line was what made me wonder if this post was misplaced. Nov 13 '15 at 8:49
• 1 doesn't contain either one of the factors 2,3,5,7. Nov 13 '15 at 11:30
• @mroman the linked OEIS page describes them less ambiguously as "Numbers whose prime divisors are all <= 7". Nov 13 '15 at 12:44
• @mroman - 1 doesn't contain any prime factors that aren't 2, 3, 5, or 7. That it doesn't contain those four either isn't relevant. Nov 13 '15 at 16:29