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););););); }
fromzeck(n) = { my (v=0, j); while (n, n-=2^j=valuation(n,2); v+=fibonacci(2+j);); return (v); }
todualzeck(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;); }
A374355(n) = { my (v = 0, e, x, y, b); while (n, x = y = 0; e = valuation(n, 2); for (k = 0, oo, if (bittest(n, e+k), n -= b = 2^(e+k); [x, y] = [y + b, x], v += y; break; ); ); ); return (v); }

a(n) = fromzeck(A374355(todualzeck(n)))

{
	for (n = 0, fibonacci(21)-2,
		print (n " " a(n));
	);
}

quit