mx = 25 000
nv = 0
os = Set([])
s = Set([])

see(n) = nv++; \
	s = setunion(s, Set([n]));	\
	if (nv%1000==0,	\
		os = setunion(os, s); s = Set([])	\
	);	\
	print (nv " " n)

seen(n) = return (setsearch(s,n)>0 || setsearch(os,n)>0)

other(p) =	\
	see(p);	\
	my (m=2*p);	\
	while (1,	\
		if (!seen(m),	\
			fordiv(m, d, 	\
				if (d<m && !seen(d),	\
					see(m);	\
					return (d)	\
				)	\
			)	\
		);	\
		m += p	\
	)

{
	a = 1;
	for (n=1, mx/2,
		a = other(a);
	)
}

quit