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

3

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.

txizzle

Posted 2015-11-13T08:42:39.187

Reputation: 131

Question was closed 2015-11-13T09:39:57.930

@Calvin'sHobbies: I thought that too, but the very last line was what made me wonder if this post was misplaced. – El'endia Starman – 2015-11-13T08:49:48.373

1 doesn't contain either one of the factors 2,3,5,7. – mroman – 2015-11-13T11:30:00.370

1@mroman the linked OEIS page describes them less ambiguously as "Numbers whose prime divisors are all <= 7". – trichoplax – 2015-11-13T12:44:17.653

@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. – Glen O – 2015-11-13T16:29:44.443

No answers