OFFSET
0,4
COMMENTS
A binary index of n is any position of a 1 in its reversed binary expansion. The binary indices of n are row n of A048793.
The k-th composition in standard order (graded reverse-lexicographic, A066099) is obtained by taking the set of positions of 1's in the reversed binary expansion of k, prepending 0, taking first differences, and reversing again. This gives a bijective correspondence between nonnegative integers and integer compositions.
LINKS
John Tyler Rascoe, Table of n, a(n) for n = 0..8192
John Tyler Rascoe, Python code.
EXAMPLE
The binary indices of 27 are {1,2,4,5}, with maximal runs ((1,2),(4,5)), with lengths (2,2), which is the 10th composition in standard order, so a(27) = 10.
The binary indices of 100 are {3,6,7}, with maximal runs ((3),(6,7)), with lengths (1,2), which is the 6th composition in standard order, so a(100) = 6.
MATHEMATICA
bpe[n_]:=Join@@Position[Reverse[IntegerDigits[n, 2]], 1];
stcinv[q_]:=Total[2^(Accumulate[Reverse[q]])]/2;
Table[stcinv[Length/@Split[bpe[n], #2==#1+1&]], {n, 0, 100}]
PROG
(Python) # see links
CROSSREFS
KEYWORD
nonn,easy
AUTHOR
Gus Wiseman, Jul 16 2025
STATUS
approved
