To find the nilpotent elements of $\Bbb Z_n$ and also the number of nilpotent elements of $\Bbb Z_n$. I am trying to find the nilpotent elements of $\Bbb Z_n$ and also the number of nilpotent elements of $\Bbb Z_n$.
My Try: If $\bar a$ be a nilpotent element then there exists a $k \in \Bbb Z$ such that $(\bar a)^k = \bar 0$, then $n$ is a factor of $a^k$. Then it follows that $(\bar a)^k = \bar 0$ for some $k$ iff each prime factor of $n$ is a factor of $a$.
Is the above proof correct??
But how can I find the number of nilpotent elements of $\Bbb Z_n$??
 A: If $n=p_1^{r_1}\dots p_k^{r_k}$, we have:
$$\mathbf Z/n\mathbf Z\simeq\mathbf Z/p_1^{r_1}\mathbf Z\times\dotsm\times\mathbf Z/ p_k^{r_k}\mathbf Z $$
An element in $\mathbf Z/n\mathbf Z$ is nilpotent if and only if its images in each of $\mathbf Z/p_i^{r_i}\mathbf Z,\enspace i=1,\dots, k$, are nilpotent. Now the nilradical of $\mathbf Z/p_i^{r_i}\mathbf Z$ is the ideal:
$$p_i\mathbf Z/p_i^{r_i}\mathbf Z\simeq \mathbf Z/p_i^{r_i-1}\mathbf Z$$
which contains $p_i^{r_i-1}$ elements. Thus the number of nilpotent elements in $\mathbf Z/n\mathbf Z$ is
$$ p_1^{r_1-1}\dotsm p_k^{r_k-1}=\frac n{p_1\dotsm p_k}. $$
and the set of nilpotents elements in $\mathbf Z/n\mathbf Z$ by the above isomorphism, is:
$$(p_1\dotsm p_k)\mathbf Z/n\mathbf Z.$$
A: Answer: Using the chinese remaider lemma you get a general formula for the nilradical $nil(\mathbb{Z}/n\mathbb{Z})$ for any integer $n$ as follows:
In general if $n:=p_1^{l_1}\cdots p_d^{l_d}$ with $p_i\neq p_j$ primes for all $i\neq j$, and $l_i\geq 2$ for some $i$, the ring $R:=\mathbb{Z}/n\mathbb{Z}$ will have non-trivial nilpotent elements. The nilradical in $R$ will be the ideal
$$ nil(R):=((p_1),..,(p_d))$$
in the crl-decomposition
$$R \cong \mathbb{Z}/(p_1^{l_1}) \mathbb{Z}   \oplus \cdots \oplus \mathbb{Z}/(p_d^{l_d}) \mathbb{Z}$$
and $nil(R)$ will be nontrivial if $l_i\geq 2$ for some $i$. Define
$$\mathfrak{m}_i:=((1),..,(p_i),..,(1)) \subseteq B$$
it follows $\mathfrak{m}_i$ for $i=1,..,d$ are the maximal ideals of $R$. These are coprime ideals and it follows
$$nil(R)= \cap \mathfrak{m}_i=\prod \mathfrak{m}_i=((p_1),..,(p_d)).$$
If $l_i=1$ for all $i$, it follows $R$ is a product of fields which is a reduced ring.
