tozeck(n) = { for (i=0, oo, if (n<=fibonacci(2+i), my (v=0, f); forstep (j=i, 0, -1, if (n>=f=fibonacci(2+j), n-=f; v+=2^j;); if (n==0, return (v););););); } todualzeck0(n) = { my (s=0, v=0); for (i=0, oo, if (s>=n, forstep (j=i-1, 0, -1, if (s-fibonacci(2+j)>=n, s-=fibonacci(2+j); v-=2^j;);); return (v);); s+=fibonacci(2+i); v+=2^i;); } cache = [todualzeck0(1)] todualzeck(n) = { while (#cache < n, cache = concat(cache, apply (todualzeck0, [#cache+1..2*#cache])); ); if (n, cache[n], 0); } s = 0 unseen = 1 seen(v) = bittest(s, v) see(v) = s = bitor(s, 2^v); while (seen(unseen), unseen++) missing(n) = 2^#binary(n)-1-n other(n) = { my (zn = tozeck(n)); for (v = unseen, oo, if (!seen(v) && bitand(missing(todualzeck(v)), zn)==0, see(v); return (v); ); ); } { a = vector(10 000); u = 1; print ("0 0"); for (n = 1, oo, v = other(n); if (v <= #a, a[v] = n; while (a[u], print (u " " a[u]); if (u++ > #a, break (2); ); ); ); ); } quit