%I #30 Apr 18 2021 10:08:28
%S 1,3,9,24,66,180,486,1314,3558,9606,25956,70134,189462,511866,1382880,
%T 3735888,10092762,27266340,73661610,199001490,537615066,1452399978,
%U 3923748270
%N Number of ternary cubefree words of length n.
%H A. M. Shur, <a href="http://dx.doi.org/10.1016/j.cosrev.2012.09.001">Growth properties of power-free languages</a>, Computer Science Review, Vol. 6 (2012), 187-208.
%H A. M. Shur, <a href="http://arxiv.org/abs/1009.4415">Numerical values of the growth rates of power-free languages</a>, arXiv:1009.4415 [cs.FL], 2010.
%H Eric Weisstein's World of Mathematics, <a href="http://mathworld.wolfram.com/CubefreeWord.html">Cubefree Word.</a>
%F Let L = lim a(n)^(1/n); then L exists since a(n) is submultiplicative. 2.7015614 < L < 2.7015616 (Shur 2012); the gap between the bounds can be made less than any given constant. - _Arseny Shur_, Apr 27 2015
%e There are 81 ternary words of length 4. Five of them contain the cube 000: 0000, 0001, 0002, 1000, 2000; same for 111 and 222. So, a(4)=81-3*5=66. - _Arseny Shur_, Apr 27 2015
%o (Python)
%o from itertools import product
%o def cf(s):
%o for l in range(1, len(s)//3 + 1):
%o for i in range(len(s) - 3*l + 1):
%o if s[i:i+l]*2 == s[i+l:i+3*l]: return False
%o return True
%o def a(n):
%o if n == 0: return 1
%o return 3*sum(cf("0"+"".join(w)) for w in product("012", repeat=n-1))
%o print([a(n) for n in range(14)]) # _Michael S. Branicky_, Apr 16 2021
%Y Cf. A028445.
%K nonn
%O 0,2
%A _Eric W. Weisstein_
%E More terms from _Sascha Kurz_, Mar 22 2002
%E a(19)-a(22) from _Michael S. Branicky_, Apr 16 2021