A256696 R(k), the minimal alternating binary representation of k, concatenated for k = 0, 1, 2,....
0, 1, 2, 4, -1, 4, 8, -4, 1, 8, -2, 8, -1, 8, 16, -8, 1, 16, -8, 2, 16, -8, 4, -1, 16, -4, 16, -4, 1, 16, -2, 16, -1, 16, 32, -16, 1, 32, -16, 2, 32, -16, 4, -1, 32, -16, 4, 32, -16, 8, -4, 1, 32, -16, 8, -2, 32, -16, 8, -1, 32, -8, 32, -8, 1, 32, -8, 2, 32
Offset: 0
Examples
R(0) = 0 R(1) = 1 R(2) = 2 R(3) = 4 - 1 R(4) = 4 R(9) = 8 - 4 + 1 R(11) = 16 - 8 + 4 - 1
References
- D. E. Knuth, The Art of Computer Programming. Addison-Wesley, Reading, MA, 1981, Vol. 2 (2nd ed.), p. 196, Exercise 27.
Links
- Clark Kimberling, Table of n, a(n) for n = 0..1000
Crossrefs
Programs
-
Mathematica
z = 100; b[n_] := 2^n; bb = Table[b[n], {n, 0, 40}]; s[n_] := Table[b[n + 1], {k, 1, b[n]}]; h[0] = {1}; h[n_] := Join[h[n - 1], s[n - 1]]; g = h[10]; r[0] = {0}; r[n_] := If[MemberQ[bb, n], {n}, Join[{g[[n]]}, -r[g[[n]] - n]]] u = Flatten[Table[r[n], {n, 0, z}]]
Comments