z = 250;
"The sequence s:" (* A001651, (3n/2) *)
s = Table[Floor[3 n/2], {n, 1, z}]
"The sequence t:" (* A016789; congr to 0 or 1 mod 3; *)
t = Complement[Range[Max[s]], s]
s1[n_] := Length[Intersection[Range[n - 1], s]];
t1[n_] := n - 1 - s1[n];
"The sequence s1:"
Table[s1[n], {n, 1, z}] (* A004396 *)
"The sequence t1:"
Table[t1[n], {n, 1, z}] (* A002264 *)
w[1] = {0}; w[t[[1]]] = {1};
w[n_] := If[MemberQ[s, n], Join[{0}, w[s1[n]]], Join[{1}, w[t1[n]]]]
"List tt of all binary words:"
tt = Table[w[n], {n, 1, z}] (* all the binary words *)
"All the words, concatenated:"
Flatten[tt] (* words, concatenated, A344150 *)
"Positions of words in which #0's = #1's:" (* A344151 *)
Select[Range[Length[tt]], Count[tt[[#]], 0] == Count[tt[[#]], 1] &]
"Positions of words in which #0's < #1's:" (* A344152 *)
Select[Range[Length[tt]], Count[tt[[#]], 0] < Count[tt[[#]], 1] &]
"Positions of words in which #0's > #1's:" (* A344153 *)
Select[Range[Length[tt]], Count[tt[[#]], 0] > Count[tt[[#]], 1] &]
"Positions of words ending with 0:" (* A344154 *)
Select[Range[Length[tt]], Last[tt[[#]]] == 0 &]
"Positions of words ending with 1:" (* A344155 *)
Select[Range[Length[tt]], Last[tt[[#]]] == 1 &]
"Positions of words starting and ending with same digit:" (* A344156 *)
Select[Range[Length[tt]], First[tt[[#]]] == Last[tt[[#]]] &]
"Positions of words starting and ending with opposite digits:" (* A344157 *)
Select[Range[Length[tt]], First[tt[[#]]] != Last[tt[[#]]] &]
"Positions of words starting with 0 and ending with 0:" (* A344158 *)
Select[Range[Length[tt]], First[tt[[#]]] == 0 && Last[tt[[#]]] == 0 &]
"Positions of words starting with 0 and ending with 1:" (* A344159 *)
Select[Range[Length[tt]], First[tt[[#]]] == 0 && Last[tt[[#]]] == 1 &]
"Positions of words starting with 1 and ending with 0:" (* A344160 *)
Select[Range[Length[tt]], First[tt[[#]]] == 1 && Last[tt[[#]]] == 0 &]
"Positions of words starting with 1 and ending with 1:" (* A344161 *)
Select[Range[Length[tt]], First[tt[[#]]] == 1 && Last[tt[[#]]] == 1 &]
"Position of n-th positive integer (base 2) in tt: A344162 "
d[n_] := If[First[w[n]] == 1, FromDigits[w[n], 2]];
Flatten[Table[Position[Table[d[n], {n, 1, 200}], n], {n, 1, 200}]]
"Position of binary complement of w(n): A344163"
comp = Flatten[Table[Position[tt, 1 - w[n]], {n, 1, 50}]]
"Sum of digits of w(n): A344164"
Table[Total[w[n]], {n, 1, 100}]
"Number of runs in w(n): A344165"
Map[Length, Table[Map[Length, Split[w[n]]], {n, 1, 100}]]
"Palindromes:"
Select[tt, # == Reverse[#] &]
"Positions of palindromes: A344166"
Select[Range[Length[tt]], tt[[#]] == Reverse[tt[[#]]] &]
"Positions of words in which #0's - #1's is odd: A344167"
Select[Range[Length[tt]], OddQ[Count[w[#], 0] - Count[w[#], 1]] &]
"Positions of words in which #0's - #1's is even: A344168"
Select[Range[Length[tt]], EvenQ[Count[w[#], 0] - Count[w[#], 1]] &]
"Position of the reversal of the n-th word: A344169"
Flatten[Table[Position[tt, Reverse[w[n]]], {n, 1, 150}]]
|