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++)

find(s) = {
	fordiv (s, d,
		if (!seen(d),
			see(d);
			return (d);
		);
	);
	print ("# the end");
	quit;
}

for (n=1, 2 500, print (n " " find(numbpart(n))))

quit