OFFSET
1,3
COMMENTS
An interval such as {3,4,5} is a set of positive integers with all differences of adjacent elements equal to 1.
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
EXAMPLE
The terms and corresponding intervals begin:
0: ()
1: (1)
2: (2)
4: (3)
6: (1,2)
8: (4)
16: (5)
20: (2,3)
32: (6)
52: (1,2,3)
64: (7)
72: (3,4)
128: (8)
256: (9)
272: (4,5)
328: (2,3,4)
512: (10)
840: (1,2,3,4)
MATHEMATICA
stc[n_]:=Differences[Prepend[Join @@ Position[Reverse[IntegerDigits[n, 2]], 1], 0]]//Reverse;
chQ[y_]:=Length[y]<=1||Union[Differences[y]]=={1};
Select[Range[0, 1000], chQ[stc[#]]&]
CROSSREFS
KEYWORD
nonn
AUTHOR
Gus Wiseman, Sep 24 2022
STATUS
approved