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

base = 10
has(m,n) = {
	my (w=base^#digits(n, base));
	while (m>=n,
		if (m%w==n, return (1), m\=base);
	);
	return (0);
}

other(n) = {
	for (v=unseen, oo,
		if (!seen(v) && has(n*v, n),
			see(v);
			return (v);
		);
	);
}

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

quit