Number of ring endomorphisms of $\mathbb{Z}[\zeta_n]$ Let $n \in \mathbb{N}$ and $\zeta_n = e^{2i\pi/n} $ we define the following subring of $\mathbb{C}$ by,
$$\mathbb{Z}[\zeta_n] = \{ P(\zeta_n) : P \in \mathbb{Z}[x]\}$$
One can easily show that,
$$\mathbb{Z}[\zeta_n] = \{a_0+a_1 \zeta_n+\dots+a_{n-1} \zeta_n^{n-1} : a_i \in \mathbb{Z} \}$$
My question is about the number $N_n$ of ring endomorphisms of $\mathbb{Z}[\zeta_n]$.

My work so far :
If $f : \mathbb{Z}[\zeta_n] \rightarrow \mathbb{Z}[\zeta_n]$ is a ring morphism then as $\mathbb{Z}[\zeta_n]$ is a subring of $\mathbb{C}$ we have, $f(m) = m$ for all $m \in \mathbb{Z}$. From that we easily deduce that for any element of $\mathbb{Z}[\zeta_n]$ we must have,
$$f\left(\sum_{i=0}^{n-1} a_i(\zeta_n)^i \right)=\sum_{i=0}^{n-1} a_if(\zeta_n)^i$$
And more generally,
$$\forall P \in \mathbb{Z}[x],f(P(\zeta_n))= P(f(\zeta_n)) $$
Moreover, as we know that $f(1) = 1$ and $\zeta_n^n = 1$ then $f(\zeta_n)^n=f(\zeta_n^n) = f(1) = 1$. Hence, $f(\zeta_n)$ is a $n$th root of unity, so there exists $0\leq k \leq n-1$ such that $f(\zeta_n) = \zeta_n^k$.
Therefore $N_n \leq n$. If we only considered the number of group morphisms then the answer would be $n$, but here having a ring morphism is far more restrictive, and we can see on simple examples that it should not be the case.
Indeed, $\mathbb{Z}[\zeta_1] = \mathbb{Z}[\zeta_2] = \mathbb{Z}$, thus $N_1 =N_2 = 1$. Likewise, $\mathbb{Z}[\zeta_4] = \mathbb{Z}[i]$ where there are only two ring morphisms, so $N_4 = 2$.
From this observation, I deduced the following conjecture
$$\forall n \in \mathbb{N}, N_n = \varphi(n) $$
where $\varphi$ denotes the Euler's totient function.
My hope would be to show that $f(\zeta_n) = \zeta_n^k$ has to be a generator of the cyclic group of the $n$th roots of unity, that is to say $k$ and $n$ are coprimes.
Equivalently, I want to prove that the map,
$$f : P(\zeta_n) \in \mathbb{Z}[\zeta_n] \mapsto P(\zeta_n^k) \in \mathbb{Z}[\zeta_n]$$
is only well-defined when $k \wedge n = 1$ (i.e. $f(P(\zeta_n))$ does not depend on the choice of $P$). From this point on, it will be easy to prove that $f$ is indeed a ring morphism.
If $P = a_0+a_1x+\dots+a_p x^p \in \mathbb{Z}[x]$ and $Q = b_0+b_1x+\dots+b_q x^q \in \mathbb{Z}[x]$ are such that $P(\zeta) = Q(\zeta)$ where $\zeta$ is any generator of the $n$th roots of unity, then we have,
$$\sum_{j=0}^{n-1} \left( \sum_{i \equiv j [n]} a_i \right)\zeta^j = \sum_{j=0}^{n-1} \left(\sum_{i \equiv j [n]} b_i \right) \zeta^j$$
But somehow I have difficulties going further, does this equality for one generator implies that all coefficients involved must be equal? Is $(1,\zeta,\dots,\zeta^{n-1})$ some sort of basis? What happens when $k$ and $n$ are not coprimes, are there any simple counter examples?

I possibly could have missed simpler arguments. What are you thoughts on this problem and on my reasoning? Any hint or suggestion will be welcomed.

Edit - current status : Thanks to Rob Arthan's answer, we deduce that $k$ being coprime with $n$ is a necessary condition for $f$ to be a ring homomorphism which leads me to,
$$N_n \leq \varphi(n) $$
I want to show that this number is reached by defining $\varphi(n)$ different ring homomorphisms.
Some observations:

*

*As $\zeta_n^k$ is a primitive $n$th root of unity then $\Bbb{Z}[\zeta_n] = \Bbb{Z}[\zeta_n^k]$.


*I realised that if,
$$\sum_{j=0}^{n-1} a_j \zeta_n^j = 0 $$
$\qquad$ then all $a_j$ are not necessarily zero, but this was to be expected.
As Z Wu pointed out, the cyclotomic polynomials come in handy for this problem that involves primitive roots of unity. I really like this approach, but I am not supposed to know anything about cyclotomic polynomials in my algebra course, so it led me to wonder that there must maybe exist a more elementary approach.
 A: First a couple of asides:
(1) a neater definition of $\Bbb{Z}[\zeta_n]$ is that it is the smallest subring of $\Bbb{C}$ containing $\zeta_n$ - I think concentrating on the that fact it comprises polynomial expressions in $\zeta_n$ has led you a bit off track;
(2) $\mathbb{Z}[\zeta_n] = \{a_0+a_1 \zeta_n+\dots+a_{n-1} \zeta_n^{n-1} : a_i \in \mathbb{Z} \}$ is only right for odd $n$: if $n = 2k$, then $\mathbb{Z}[\zeta_n] = \{a_0+a_1 \zeta_n+\dots+a_{n-1} \zeta_n^{k-1} : a_i \in \mathbb{Z} \}$ (because in that case, $\zeta_n^k = -1 \in \Bbb{Z}$).
That said, your conjecture is correct. As you observe, if $f : \Bbb{Z}[\zeta_n] \to \Bbb{Z}[\zeta_n]$ is any homomorphism, then $f(\zeta_n)$ is an $n$-th root of unity and hence is equal to $\zeta_n^k$ for some $k$. To prove your conjecture, you need to show that $k$ and $n$ are coprime. To see this, assume we have $k = mk'$ and $n = mn'$. We need to show that $m = 1$. We have:
$$
f(\zeta_m) = f(\zeta_n^{n'}) = f(\zeta_n)^{n'} = (\zeta_n^k)^{n'} = (\zeta_{mn'}^{mk'})^{n'} = \zeta_{mn'}^{mk'n'} = 1
$$
(Here I am using the assumption that $f$ is a ring homomorphism and identities such as $\zeta_a = \zeta_{ab}^b$ and $\zeta_a^{ab} = 1$ that are easily verified).
But $\zeta_m$ is an $m$-th root of unity, hence, if $m \neq 1$, $1 + \zeta_m + \zeta_m^2 + \dots +\zeta_m^{m-1} = 0$, so we have
$$
\begin{align*}
0 &= f(1 + \zeta_m + \zeta_m^2 + \dots +\zeta_m^{m-1})\\
  &= f(1) + f(\zeta_m) + f(\zeta_m)^2 + \dots + f(\zeta_m)^{m-1}\\
  &= m
\end{align*}
$$
giving a contradiction unless $m = 1$.
[As a hint for how to find proofs like this: try some small examples. I looked at the case $n = 4$ and $k = 2$, which is a little bit too easy, but gives some clues, and then at $n = 30$ and $k = 12$, which exhibits all the issues needed for the general case.]
A: Here is the elementary version (which still requires a non-trivial fact).
Let us understand the structure of $\mathbb{Z}[\zeta_n]$ first.
It is the image of the ring map $f:\mathbb{Z}[X]\to \mathbb{C},X\mapsto \zeta_n$. Hence $$\mathop{\mathrm{Im}}f\cong\frac{\mathbb{Z}[X]}{\ker f}$$
Let $m(X)\in\mathbb{Q}[X]$ be the minimal polynomial of $\zeta_n$ over $\mathbb{Q}$. It divides $X^n-1$ in $\mathbb{Q}[X]$ and it is monic, using Gauss's lemma for polynomials (should be in any textbook of commutative algebra, or check this question), we know $m(X)$ divides $X^n-1$ in $\mathbb{Z}[X]$, and $m(X)\in \mathbb{Z}[X]$.
Clearly $m(X)\in \ker f$. If $P(X)\in \ker f$, we have $P(\zeta_n)=0$ and thus $m$ divides $P$ in $\mathbb{Q}[X]$. Using Gauss's lemma again, we know $m$ divides $P$ in $\mathbb{Z}[X]$. Hence $$\ker f=(m(X)),\mathbb{Z}[\zeta_n]\cong \frac{\mathbb{Z}[X]}{(m(X))}.$$
Now we are ready to find endomorphisms of $\mathbb{Z}[\zeta_n]$.
{Ring maps $\phi:\frac{\mathbb{Z}[X]}{(m(X))}\to \mathbb{Z}[\zeta_n]$}  $\Leftrightarrow$
{Ring maps $\tilde{\phi}:\mathbb{Z}[X]\to \mathbb{Z}[\zeta_n]$ s.t. $\tilde{\phi}|_{(m(X))}=0$}$\Leftrightarrow$
{Ring maps $\tilde{\phi}:\mathbb{Z}[X]\to \mathbb{Z}[\zeta_n]$ s.t. $\tilde{\phi}(m(X))=0$}$\Leftrightarrow$
{Ring maps $\tilde{\phi}:\mathbb{Z}[X]\to \mathbb{Z}[\zeta_n]$ s.t. $m(\tilde{\phi}(X))=0$}$\Leftrightarrow$
{Elements $t$ in $\mathbb{Z}[\zeta_n]$ s.t. $m(t)=0$}
The last equality uses the fact that the ring maps $R[X]\to S$ are uniquely determined by ring map $R\to S$ and the image of $X$.
Since the roots of $m(X)$ form a subset of roots of $X^n-1$, which are all in $\mathbb{Z}[\zeta_n]$. We have
{Elements $t$ in $\mathbb{Z}[\zeta_n]$ s.t. $m(t)=0$}={roots of $m$}$\subset \{\zeta_n^k:0\leq k\leq n-1\}$.
Using method from Rob's answer, we know for sure that $\{\zeta_n^k:\mathop{\mathrm{gcd}}(k,n)\neq 1\}$ cannot induce a ring map. Hence

*

*$\#\{\text{roots of }m\}\leq \varphi(n)$ where $\varphi(n)$ denotes the Euler's totient function.

*Hence showing $\#\{\text{roots of }m\}= \varphi(n)$ is equivalent to showing that $\{\text{roots of }m\}=\{\zeta_n^k:\mathop{\mathrm{gcd}}(k,n)=1\}$.

And this fact is not trivial (i.e. the length of the whole proof is not suitable to present in mathstackexchange). A proof I know is the theorem 3.1 in this link.
