How many unique, prime binary sequences are there of length n, modulo rotations

combinatoricsp-adic-number-theory

How many unique, prime binary sequences are there of length $n$, modulo rotations?

I have from here the number of binary sequences modulo rotations, but that does not appear deduct for non-prime sequences, by which I mean cycles which are repetitions of shorter cycles, for example $\overline{0101}_2$ is to be excluded when counting the cardinality of the length $4$ rotations, because it is a length $2$ rotation.

$\overline{0}_2$ and $\overline{1}_2$ are the unique binary cycles of length $1$, so there are two of length $1$.

Excluding those, then $\overline{01}_2$ and $\overline{10}_2$ are the cycles of length two, but these are the same modulo rotation so there's one.

Length three, we have $\overline{001}_2\cong\overline{010}_2\cong\overline{100}_2$ and $\overline{011}_2\cong\overline{101}_2\cong\overline{110}_2$ so again there are two.

Length four, I'm counting out $\overline{0101}_2$ and $\overline{1010}_2$ because those aren't "prime", they're duplicates of the length two cycle. That leaves $\overline{0111}_2\cong\overline{1110}_2\cong\overline{1101}_2\cong\overline{1011}_2$ and $\overline{1000}_2\cong\overline{0001}_2\cong\overline{0010}_2\cong\overline{0100}_2$ – so there are two distinct ones of length four.

Five is a prime number so only the length one cycles to exclude – leaving I think six possibilities: $\overline{00001}_2\neq\overline{00011}_2\neq\overline{00111}_2\neq\overline{01111}_2\neq\overline{10101}_2\neq\overline{01010}_2$

Six – we exclude the cycles of length $1,2,3$ giving us $111110,000001,110000,001111,111000,101000,010111,110010,001101$

Unless I've made a mistake we have the sequence $2,1,2,2,6,9\ldots$ or $1,2,1,2,2,6,9\ldots$ if we count one empty string, neither of which has a relevant record in OEIS.

I've included the p-adic numbers tag because these count the number of distinct $2$-adic orbits under the action of truncation.

Best Answer

The standard terminology is that a word is aperiodic if it doesn't consist of repetitions of another word. Given an aperiodic word we can consider its cyclic rotations, and among all of them there is a unique smallest one in lexicographic order; so these words correspond bijectively to orbits of aperiodic words modulo cyclic rotation. They're called Lyndon words, and they can be counted using Mobius inversion as follows.

Write $M(a, n)$ for the number of Lyndon words of length $n$ on an alphabet of size $a$. An arbitrary word of length $n$ factors uniquely as a cyclic rotation of a Lyndon word of length $d$, raised to the power of $\frac{n}{d}$, for some $d \mid n$. This gives

$$a^n = \sum_{d \mid n} d M(a, d)$$

and Mobius inversion applied to this expression gives the necklace polynomial

$$M(a, n) = \frac{1}{n} \sum_{d \mid n} \mu \left( \frac{n}{d} \right) a^d$$

where $\mu$ is the Mobius function.

Now for some amusing trivia: when $a = q$ is a power of a prime this also counts irreducible polynomials of degree $n$ over $\mathbb{F}_q$ (also by a Mobius inversion argument) and these can be put in bijection with Lyndon words; see this math.SE question. When $n = p$ is prime we get that $\frac{a^p - a}{p}$ is an integer so this gives a bijective proof of Fermat's little theorem. When $n$ is composite we get a "necklace congruence" $\sum_{d \mid n} \mu \left( \frac{n}{d} \right) a^d \equiv 0 \bmod n$ which gives a generalization of Fermat's little theorem different from the totient theorem. The necklace polynomials also count the dimensions of the graded pieces of the free Lie algebra on $a$ generators.

For $a = 2$ this sequence is A001037 on the OEIS; you have a mistake in your sequence at $n = 4$ because you missed $0011$.