A171761 Number of ternary squareful words of length n.
0, 0, 3, 15, 63, 213, 687, 2127, 6483, 19575, 58905, 176943, 531177, 1593981, 4782513, 14348289, 43045923, 129139119, 387419097, 1162259637, 3486782013, 10460350023, 31381055463, 94143173409
Offset: 0
Keywords
Programs
-
Mathematica
nmax = 23; 3^Range[0, nmax] - Length /@ NestList[ DeleteCases[ Flatten[ Outer[ Append, #, {1, 2, 3}, 1], 1], {_, x__, x__, _}] &, {{}}, nmax] (* Jean-François Alcover, Jun 12 2017, using Vladimir Reshetnikov's code for A006156 *)