big = 1 000 000 s = 0 S = [] unseen = 1 seen(v) = if (v < big, bittest(s, v), setsearch(S, v)) see(v) = if (v < big, s = bitor(s, 2^v), S = setunion(S, [v])); while (seen(unseen), unseen++) base = 10 other(n) = { my (d = digits(n, base)[1]); forstep (v = ceil(unseen/d)*d, oo, d, if (!seen(v), see(v); return (v); ); ); } for (n = 1, 10 000, print (n " " other(n))) quit