upto(n) = {res = List(); data = List(); for(i = 1, n, if(isprimitive(i), listput(data, i) ) ); for(i = 1, #data - 2, for(j = i+1, #data - 1, l1 = lcm(data[i], data[j]); if(l1 > n, next(2) ); for(k = j+1, #data, l2 = lcm(l1, data[k]); if(l2 > n, next(3) ); for(m = 1, n\l2, listput(res, l2*m) ) ) ) ); listsort(res, 1); res } isprimitive(n) = {if(sigma(n) < 2*n, return(0)); my(d = divisors(n)); for(i = 1, #d-1, if(sigma(d[i]) >= 2*d[i], return(0)) ); 1 }