OFFSET
1,2
COMMENTS
We define the index of a composition to be the positive integer whose binary form has run-lengths (i.e., runs of 1's, runs of 0's, etc., from left to right) equal to the parts of the composition. Example: the composition [1,1,3,1] has index 46 since the binary form of 46 is 101110.
The command c(n) from the Maple program yields the composition having index n.
LINKS
Alois P. Heinz, Table of n, a(n) for n = 1..25290
EXAMPLE
135 is in the sequence since its binary form is 10000111 and the composition [1,4,3] has no adjacent equal parts.
139 is not in the sequence since its binary form is 10001011 and the composition [1,3,1,1,2] has two adjacent equal parts.
MAPLE
Runs := proc (L) local j, r, i, k: j := 1: r[j] := L[1]: for i from 2 to nops(L) do if L[i] = L[i-1] then r[j] := r[j], L[i] else j := j+1: r[j] := L[i] end if end do: [seq([r[k]], k = 1 .. j)] end proc: RunLengths := proc (L) map(nops, Runs(L)) end proc: c := proc (n) ListTools:-Reverse(convert(n, base, 2)): RunLengths(%) end proc: pd := proc (n) options operator, arrow: product(c(n)[j]-c(n)[j+1], j = 1 .. nops(c(n))-1) end proc: A := {}; for n to 200 do if pd(n) <> 0 then A := `union`(A, {n}) else end if end do: A; # most of the Maple program is due to W. Edwin Clark
MATHEMATICA
With[{nn = 18}, TakeWhile[#, # <= Floor[2^(2 + nn/Log2[nn])] &] &@ Union@ Apply[Join, #] &@ Table[Map[FromDigits[#, 2] &@ Flatten@ MapIndexed[ConstantArray[Boole@ OddQ@ #2, #1] &, #] &, Select[Map[Flatten[Map[# /. w_List :> If[First@ w == 1, Length@ w + 1, ConstantArray[1, Length@ w]] &, Split@ #] /. {a__, b_List, c__} :> {a, Most@ b, c}] &@ PadLeft[#, n - 1] &, IntegerDigits[Range[0, 2^n - 1], 2]], FreeQ[Differences@ #, 0] &]], {n, 2, nn}]] (* Michael De Vlieger, Jan 24 2018 *)
CROSSREFS
KEYWORD
nonn
AUTHOR
Emeric Deutsch, Jan 24 2018
STATUS
approved