ok(x,y,z) =	\
	if (x==0 || y==0 || z==0, return (1),	\
	    (y+z) % x==0, return (1),	\
	    (x+z) % y==0, return (1),	\
	    (x+y) % z==0, return (1),	\
					  return (0))

seen = 0

a1 = 5

choose(n,x,y) =	\
	local (z=if (n==1, a1, 1));	\
	while (bittest(seen, z) || !ok(x,y,z), z++);	\
	seen += 2^z;	\
	return (z)

{
	x = 0;
	y = 0;
	for (n=1, 10 000,
		z = choose(n,x,y);
		print (n " " z);
		x = y;
		y = z;
	)
}

quit