login
Number of binary strings of length n having exactly one factorization as a concatenation of palindromes of length >= 2.
4

%I #18 Jul 28 2021 14:15:41

%S 0,2,4,4,18,22,64,96,188,388,648,1248,2040,3784,6544,11162,19356,

%T 32396,55768,93678,157308,263308,438512,731198,1211304,2004076,

%U 3306552,5445588,8955544,14690980,24061172,39360032

%N Number of binary strings of length n having exactly one factorization as a concatenation of palindromes of length >= 2.

%C Terms are even by symmetry. - _Michael S. Branicky_, Jul 28 2021

%e a(4) = 4, because {0011, 0110, 1001, 1100} have unique factorizations into palindromes of length >= 2.

%o (Python)

%o from functools import lru_cache

%o from itertools import product

%o def ispal(s): return s == s[::-1]

%o @lru_cache(maxsize=None)

%o def f(b): # factorizations of binary string b

%o factorizations = int(len(b) >= 2 and ispal(b))

%o for i in range(2, len(b)-1):

%o factorizations += ispal(b[:i]) * f(b[i:])

%o if factorizations >= 2: return 2 # short circuit on condition

%o return factorizations

%o def a(n):

%o return 2*sum(f("0"+"".join(b))==1 for b in product("01", repeat=n-1))

%o print([a(n) for n in range(1, 16)]) # _Michael S. Branicky_, Jul 28 2021

%Y Cf. A241208, A241210.

%K nonn,more

%O 1,2

%A _Jeffrey Shallit_, Apr 17 2014

%E a(17)-a(30) from _Giovanni Resta_, Apr 18 2014

%E a(31)-a(32) from _Michael S. Branicky_, Jul 28 2021