Bit of an x y problem here, so in full disclosure, I am attempting to find the next term of A152617, "Smallest number m such that m has exactly n distinct prime factors and sigma(m) has exactly n distinct prime factors."
But my main question is, how do you generate all numbers with n distinct prime factors in order? For small n, it's feasible to iterate through the natural numbers and factor each, but for the next term of A152617, getting to even the first number with 13 distinct prime factors (the 13th primorial) in this way is computationally intractable.
Looking at small cases, such as n=4, it seems to be some sort of combinatoric operation of primes and prime powers:
210 = 2 · 3 · 5 · 7
330 = 2 · 3 · 5 · 11
390 = 2 · 3 · 5 · 13
420 = 2^2 · 3 · 5 · 7
462 = 2 · 3 · 7 · 11
510 = 2 · 3 · 5 · 17
546 = 2 · 3 · 7 · 13
570 = 2 · 3 · 5 · 19
630 = 2 · 3^2 · 5 · 7
660 = 2^2 · 3 · 5 · 11
...
Normally, if there was a sporadically growing pattern with two degrees of freedom, to enumerate them in order, I would "batch" all of them in some range, and then sort. But with this problem, the prime powers replace primes, the prime powers can be any size, primes can become arbitrarily large, primes can be missing, so I'm unsure how to even go about choosing an order to enumerate the space due to all the degrees of freedom.
It seems there is an efficient PARI program on A033993 that might encode the algorithm I seek, but I have not yet been able to translate this code into a mental model of an algorithm, and found it more in my current ability to write this question. I've copied the code here for posterity:
(PARI) A246655(lim)=my(v=List(primes([2, lim\=1]))); for(e=2, logint(lim, 2), forprime(p=2, sqrtnint(lim, e), listput(v, p^e))); Set(v)
list(lim, pr=4)=if(pr==1, return(A246655(lim))); my(v=List(), pr1=pr-1, mx=prod(i=1, pr1, prime(i))); forprime(p=prime(pr), lim\mx, my(u=list(lim\p, pr1)); for(i=1, #u, listput(v, p*u[i]))); Set(v) \\ Charles R Greathouse IV, Feb 03 2023