I would like to present the algebraic aspects of this problem to
facilitate understanding. Suppose we have $r$ types of objects
(e.g. colors) with $k_1 + k_2 + \cdots + k_r = n$ objects total where
$k_q$ gives the number of objects of color $q$ and we ask about the
number of necklaces we can form with these (rotational symmetry as
opposed to dihedral symmetry).
Applying the Polya Enumeration Theorem (PET) we have the cycle
index of the cyclic group
$$Z(C_n) = \frac{1}{n}\sum_{d|n} \varphi(d) a_d^{n/d}.$$
PET now yields for the generating function of necklaces using at most
$r$ colors
$$q_n = \frac{1}{n}\sum_{d|n}
\varphi(d) (A_1^d + A_2^d +\cdots+A_r^d)^{n/d}.$$
We now introduce the concept of primitive necklaces $p_n$ i.e.
necklaces on at most $r$ colors not having any rotational
symmetry. Observe that an ordinary necklace is formed by concatenating
$d$ copies of a primitive necklace of size $n/d.$ (In fact it does not
matter where we open the primitive necklace ($n/d$ possibilities)
because when we arrange the copies of the opened necklace we always
get the same necklace regardless of where we opened the primitive
necklace.)
We will use a variety of Moebius inversion which is
Inclusion-Exclusion on the divisor poset in order to compute $p_n$ (a
generating function) and extract the desired coefficient. The possible
symmetries that can occur correspond to the divisors $f$ of $n$
($f|n$).
Using the variable $f$ we obtain as explained a segment of length
$n/f$ being repeated $f$ times, copies being placed next to each
other, thus creating $n/f$ cycles of length $f.$. These segments are
themselves necklaces of length $n/f.$ This means that the maximal
symmetry (smallest size of the constituent cycles) is a divisor of
$n/f$ because the segment could itself be a concatenation of repeated
segments. Ordering these in a poset by division yields an upside-down
instance of the divisor poset of $n$. Note that the generating
function for the contribution from $f$ is not
$$\frac{1}{n/f}\sum_{d|n/f}
\varphi(d) (A_1^d + A_2^d + \cdots + A_r^d)^{n/f/d}.$$
but rather
$$\frac{1}{n/f}\sum_{d|n/f}
\varphi(d) (A_1^{df} + A_2^{df} + \cdots + A_r^{df})^{n/f/d}.$$
which represents the $f$ copies of the source segment.
We thus obtain by Inclusion-Exclusion
$$\sum_{f|n} \mu(f)
\frac{f}{n}\sum_{d|n/f}
\varphi(d) (A_1^{df} + A_2^{df} + \cdots + A_r^{df})^{n/f/d}.$$
We put $fd=k$ so that $d=k/f$ to get
$$\sum_{f|n} \mu(f)
\frac{f}{n}\sum_{k/f|n/f}
\varphi(k/f) (A_1^{k} + A_2^{k} + \cdots + A_r^{k})^{n/k}
\\ = \frac{1}{n}
\sum_{f|n} f\mu(f)
\sum_{k|n \wedge f|k}
\varphi(k/f) (A_1^{k} + A_2^{k} + \cdots + A_r^{k})^{n/k}
\\ = \frac{1}{n}
\sum_{k|n} (A_1^{k} + A_2^{k} + \cdots + A_r^{k})^{n/k}
\sum_{f|k} f\mu(f) \varphi(k/f).$$
There are several ways to simplify the term
$$\sum_{f|k} f\mu(f) \varphi(k/f).$$
E.g. note that if
$$L_1(s) = \sum_{n\ge 1} \frac{n\mu(n)}{n^s}
= \prod_p \left(1-\frac{p}{p^s}\right) = \frac{1}{\zeta(s-1)}$$
and
$$L_2(s) = \sum_{n\ge 1} \frac{\varphi(n)}{n^s} =
\frac{\zeta(s-1)}{\zeta(s)}
\quad\text{because}\quad
\sum_{n\ge 1} \frac{1}{n^s} \sum_{d|n} \varphi(d)
= \zeta(s-1)$$
then
$$L_1(s) L_2(s) = \frac{1}{\zeta(s)}
\quad\text{and hence}\quad
\sum_{f|k} f\mu(f) \varphi(k/f) = \mu(k).$$
Substitute this into the formula to obtain
$$\frac{1}{n}
\sum_{k|n} \mu(k) (A_1^{k} + A_2^{k} +\cdots + A_r^{k})^{n/k}.$$
We seek
$$[A_1^{k_1} A_2^{k_2} \cdots A_r^{k_r}] \frac{1}{n}
\sum_{k|n} \mu(k) (A_1^{k} + A_2^{k} +\cdots + A_r^{k})^{n/k}.$$
Now observe that the term in the variables only produces powers that
are multiples of $k$ so we get the condition that
$$k|\gcd(n, k_1, k_2, \ldots k_r)$$
(we see that this produces a divisor of $n$) in which case we obtain a
contribution of (using $d$ for $k$ for readability)
$${n/d\choose k_1/d, k_2/d,\ldots k_r/d}$$
for an end result of
$$\frac{1}{n}\sum_{d|\gcd(k_1, k_2, \ldots k_r)}
\mu(d) {n/d\choose k_1/d, k_2/d,\ldots k_r/d}.$$
We now conclude by inspection that the sum is indeed a multiple of
$n.$
A similar problem appeared at this
MSE link.