s = 0 unseen = 1 seen(v) = bit test(s, v) see(v) = s = bit or(s, 2^v); while (seen(unseen), unseen++) other(p) = { forstep (m=2*p, oo, p, if (!seen(m), return (m); ); ); } a = vector(10 000) u = 1 nv = vector(#a) \\ n, v, skip?, next mutiple to test nb = 0 emit(n,v) = { if (v<=#a, see(v); a[v] = n; while (a[u], print (u " " a[u]); if (u++ > #a, quit; ); ); if (2*v <= #a, \\ remember this value nv[nb++] = [n,v,0,2*v]; ); ); } { emit(1,1); for (e=0, oo, w=nb; for (k=1, w, if (!nv[k][3], skip=1; forstep (m=nv[k][4], #a, nv[k][2], if (!seen(m), emit(nv[k][1]+2^e, m); nv[k][4]=m+nv[k][2]; skip=0; break; ); ); nv[k][3]=skip; ); ); \\ compress old values newnb=0; for (k=1, nb, if (!nv[k][3], nv[newnb++]=nv[k]; ); ); nb=newnb; ); } quit