login
Number of distinct critical exponents possible, over all binary strings of length n.
1

%I #8 Dec 24 2022 19:02:34

%S 1,2,3,3,5,6,9,11,14,16,20,21,27,30,33,36,44,47,55,58,63,67,76,80,89,

%T 94

%N Number of distinct critical exponents possible, over all binary strings of length n.

%C A string x has period p if x[i]=x[i+p] for all i that make sense. The shortest period is called "the" period. The exponent exp(x) of a string x of length n is defined to be n/p, where p is the period. The critical exponent of a string x is the maximum, over all nonempty contiguous subwords w of x, of exp(w).

%e For n = 6, there are 5 possible critical exponents: 6 (for 000000), 5 (for 000001), 4 (for 000011), 3 (for 000111), 2 (for 001001), and 5/2 (for 001010).

%o (Python)

%o from itertools import product

%o from fractions import Fraction

%o from functools import lru_cache

%o def period(x):

%o for p in range(1, len(x)):

%o if all(x[i] == x[i+p] for i in range(len(x)-p)):

%o return p

%o return len(x)

%o def exp(x):

%o return Fraction(len(x), period(x))

%o @lru_cache(maxsize=None)

%o def critexp(x):

%o if len(x) == 1: return 1

%o return max(exp(x), critexp(x[:-1]), critexp(x[1:]))

%o def a(n):

%o return len(set(critexp("0"+"".join(x)) for x in product("01", repeat=n-1)))

%o print([a(n) for n in range(1, 19)]) # _Michael S. Branicky_, Dec 24 2022

%K nonn,more

%O 1,2

%A _Jeffrey Shallit_, Jul 23 2018

%E a(21)-a(26) from _Michael S. Branicky_, Dec 24 2022