login
A390512
The all-integers indexing of lexicographically ordered 01 words; a bijection from the positive integers to the integers.
2
0, 1, -1, -2, 2, 3, -3, -4, -5, -6, 4, 5, 6, 7, -7, -8, -9, -10, -11, -12, -13, -14, 8, 9, 10, 11, 12, 13, 14, 15, -15, -16, -17, -18, -19, -20, -21, -22, -23, -24, -25, -26, -27, -28, -29, -30, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31
OFFSET
1,4
COMMENTS
Each binary word w having first letter 1 is identical (with letters as digits) to the binary representation of n; e.g., a(6) = 3 is the all-integers index of w = 11, and 11 is the binary representation of 3. The positions of words with first letter 1 form a dispersion as in A345254. The positions of the words having first letter 0 form a dispersion as in A390513.
FORMULA
a(n) = 1 - 2^(x-1) - k if k < 2^(x - 1), and a(n) = k if k >= 2^(x - 1), where x=floor(log_2(n + 1)) and x = n + 1 - 2^x.
EXAMPLE
In the following list, w(n) = n-th binary word in the lexicographic ordering.
n w(n) a(n)
1 0 0
2 1 1
3 00 -1
4 01 -2
5 10 2
6 11 3
7 000 -3
8 001 -4
9 010 -5
10 011 -6
11 100 4
12 101 5
MATHEMATICA
a[n_] := Module[{x, s, k, h}, x = Floor[Log[2, n + 1]];
s = 2^x - 1; k = n - s; h = 2^(x - 1); If[k < h, 1 - h - k, k ]]
t = Table[a[n], {n, 1, 100}]
TableForm[Transpose[{Range[100], t}], TableHeadings -> {None, {"n", "a(n)"}}]
CROSSREFS
KEYWORD
sign
AUTHOR
Clark Kimberling, Nov 18 2025
STATUS
approved