big = 20 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++) \\ we keep only track of small values small = [] { for (x=0, 1000, if (x>1, \\ find multiple of previous small values my (extra=[]); forstep (s=#small, 1, -1, forstep (m=ceil(unseen/small[s])*small[s], big, small[s], if (!seen(m), see(m); extra = concat(extra, m); break; ); ); ); small = concat(small,extra); ); print (x " " unseen); small = concat(small, unseen); see(unseen); if (unseen>=big, break; ); ); } quit