s = 0 unseen = 1 seen(v) = bit test(s, v) see(v) = s = bit or(s, 2^v); while (seen(unseen), unseen++) a = vector(10 000) compute(n) = { my (w=0); for (v=1, oo, w += 1 + a[n-v+1]; if (!seen(w), see(w); return (v); ); ); } for (n=1, #a, print (n " " a[n] = compute(n))) quit