upto(n) = {bases = List(); res = List([1]); 
	for(i = 1, oo, 
		nb = nbarsUpto(n, i); 
		if(#nb > 0, 
			listput(bases, nb)
		,
			break
		)
	); 
	for(i = 1, #bases, 
		q = #res; 
		for(j = 1, q, 
			for(k = 1, #bases[i],
				c = lcm(res[j], bases[i][k]); 
				if(c <= n, 
					listput(res, c)
				)
			)
		); 
		listsort(res, 1); 
	); res
	
}

nbarsUpto(n, q) = {my(res = List(), p = prime(q + 1), pr = vecprod(primes(q))); 
c = vecprod(primes(q))^q;
while(c <= n,
	listput(res, c); 
	c *= (pr * p^q); 
	p = nextprime(p + 1);  
); Vec(res)	
}