a(n) = my (f=factor(n)); prod(i=1, #f~, 3^a(f[i,2])) best = vector(10 000, k, oo) lim = 2^500 explore(n, p, mx) = { if (n <= lim, my (v=valuation(a(n), 3)); if (1+v <= #best, if (best[1+v] > n, best[1+v] = n; ); my (q=nextprime(p+1)); my (s=0); for (i=1, mx, n *= p; if (n > lim, break; ); iferr( my (z=valuation(a(i),3)); if (!bittest(s, z), s += 2^z; explore (n, q, i); ), x, "skip it" ); ); ); ); } explore(1, 2, oo); { for (k=1, #best, if (best[k] < oo, print (k-1 " " best[k]), break) ); } quit