s = 0
unseen = 1
seen(v) = bit test(s, v)
see(v) = s = bit or(s, 2^v); while (seen(unseen), unseen++)

other(p) = {
	m = 1;
	my (f=factor(p));
	for (i=1, #f~,
		m = lcm(m, prime pi(f[i,1]));
	);
	forstep (k=ceil(unseen/m)*m, oo, m,
		if (!seen(k),
			see(k);
			return (k);
		);
	);
}

v=1; for (n=1, 10 000, v=other(v); print (n " " v));

quit