|
|
A051042
|
|
Number of ternary cubefree words of length n.
|
|
3
|
|
|
1, 3, 9, 24, 66, 180, 486, 1314, 3558, 9606, 25956, 70134, 189462, 511866, 1382880, 3735888, 10092762, 27266340, 73661610, 199001490, 537615066, 1452399978, 3923748270
(list;
graph;
refs;
listen;
history;
text;
internal format)
|
|
|
OFFSET
|
0,2
|
|
LINKS
|
|
|
FORMULA
|
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
|
|
EXAMPLE
|
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
|
|
PROG
|
(Python)
from itertools import product
def cf(s):
for l in range(1, len(s)//3 + 1):
for i in range(len(s) - 3*l + 1):
if s[i:i+l]*2 == s[i+l:i+3*l]: return False
return True
def a(n):
if n == 0: return 1
return 3*sum(cf("0"+"".join(w)) for w in product("012", repeat=n-1))
|
|
CROSSREFS
|
|
|
KEYWORD
|
nonn
|
|
AUTHOR
|
|
|
EXTENSIONS
|
|
|
STATUS
|
approved
|
|
|
|