A [smooth number] is one whose factors are all "small". For a computational problem, I would like all smooth numbers up to $10^8$.
I think it's unfeasible to factor a billion numbers. Instead, I am choosing a set of primes, $P = \{2,3,5,7,11,13,17,19,23,29,31\}$. How can I find all possible product of them less than a billion?
$$\left\{ (k_2, \dots, k_{31}) : N = \prod_{p \in P} p^{k_p} < 10^9 \right\}$$
The solution is not too hard since $\log_2 10^9 = 9 \log_2 10 < 9\cdot 4 = 36 $ I never have to go too high.
My original question: I really need to index over all possible product, but how do I avoid writing 13 nested loops?