TITLE: Primitive binary necklaces
QUESTION [9 upvotes]: The problem/solution of counting the number  of (primitive) necklaces is very well known. 
But what about  results giving sufficient conditions for a given necklace be primitive? For example, in the binary case, a necklace of length $N$ (00..00100..01) will be primitive whenever the number $M$ of zeros between the two 1's is such that $\gcd(N,M)=1$.
Any idea/references for additional results of this type?

REPLY [7 votes]: The number of primitive strings of length $n$, call it $p_n$, is easy to get. The total number of length $n$ strings made of $s$ symbols is just $s^n$. All strings are made of repeats of some primitive string (in case it is primitive, it is one repeat). So:
$$
s^n = \sum_{d \mid n} p_d
$$
and Möbius inversion gives:
$$
p_n = \sum_{d \mid n} \mu(n/d) s^d
$$
Now each primitive necklace (i.e., cycle) can be cut at $n$ places to get different primitive strings, so the number of primitive necklaces is just:
$$
c_n = \frac{1}{n} \sum_{d \mid n} \mu(n/d) s^d
$$