(PARI) lista(nmax) = {my(list = List(), smax = 0, e2, e3, s); for(n = 1, nmax, e2 = valuation(n, 2); e3 = valuation(n, 3); s = if(2^e2 * 3^e3 == n, (2^(e2 + 1) - 1)*(3^(e3 + 1) - 1)/2, 0); if(s > smax, smax = s; listput(list, n))); Vec(list)};
(Python)
from sympy import multiplicity as v
from itertools import count, takewhile
def f(n): return (2**(v(2, n)+1)-1) * (3**(v(3, n)+1)-1)//2
def smooth3(lim):
pows2 = list(takewhile(lambda x: x<lim, (2**i for i in count(0))))
pows3 = list(takewhile(lambda x: x<lim, (3**i for i in count(0))))
return sorted(c*d for c in pows2 for d in pows3 if c*d <= lim)
def aupto(lim):
data, records, record = smooth3(lim), [], -1
for argv, v in zip(data, map(f, data)):
if v > record: record = v; records.append(argv)
return records