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