A298644 The indices of the Carlitz compositions (i.e., compositions without adjacent equal parts).
1, 3, 4, 6, 7, 8, 9, 14, 15, 16, 17, 24, 27, 28, 30, 31, 32, 33, 35, 36, 39, 48, 49, 54, 55, 57, 59, 60, 62, 63, 64, 65, 67, 68, 70, 72, 73, 78, 79, 96, 97, 99, 110, 111, 112, 118, 119, 120, 121, 123, 124, 126, 127, 128, 129, 131, 132, 134, 135, 136, 137, 143, 144, 145, 156, 158
Offset: 1
Keywords
Examples
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.
Links
- Alois P. Heinz, Table of n, a(n) for n = 1..25290
Programs
-
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 *)
Comments