For which $n \in \mathbb N$ does $A = \mathbb Z/ n \mathbb Z$ has $\operatorname{Nil}(A) \neq 0$? I want to try to answer the following question:
For which $n \in \mathbb N$ does $A = \mathbb Z/ n \mathbb Z$ has $\operatorname{Nil}(A) \neq 0$?
Here are my thoughts:
I know that $\operatorname{Nil}(A)$ is defined as the set of all nilpotent elements in the ring $A.$ Also, I know that $\operatorname{Nil}(A)$ is the intersection of all prime ideals of $A.$
Also, I know that $x \in A$ is nilpotent if $x^n = 0$ for some positive integer $n.$ And I know that a nilpotent element is a zero-divisor but not the converse.
Still, I am not sure how these ideas help me in solving this question, could anyone help me please?
 A: Following Geoffrey's comment, we prove that for $n > 1$, Nil$(\mathbb{Z}/n\mathbb{Z}) \neq 0$ iff $n$ is not squarefree (i.e., $n$ has a square factor). Let $n = \prod_{j=1}^r p_j^{v_j}$ be the prime factorization of $n$.
($\impliedby$): Suppose $n$ is not squarefree. Then it has a square factor--by taking the prime factorization of that square, we find that $p_i^2 | n$ for at least one $p_i$ in the factorization of $n$. Hence $c = n / p_i^2 \in \mathbb{Z}$. If we let $m = p_ic = n/p_i \in \mathbb{Z}$, then we see $0 < m \leq n-1$ and
$$
m^2 = \left(\frac{n}{p_i}\right)^2 = \frac{n^2}{p_i^2} = cn,
$$
hence $n|m^2$, yielding that $m^2 \equiv 0$ (mod $n$) and therefore $m \in$ Nil$(\mathbb{Z}/n\mathbb{Z})$. Because $m \neq 0$ in $\mathbb{Z}/n\mathbb{Z}$, we conclude Nil$(\mathbb{Z}/n\mathbb{Z}) \neq 0$ as desired.
($\implies$): Contrapositively assume $n$ is squarefree. Then none of its prime factors can have $v_j \geq 2$, lest we have $p_j^2|n$. But this means $v_j = 1$ for each $j$, that is, $n = \prod_{j=1}^r p_j$. Let $m \in\mathbb{Z}/n\mathbb{Z}$ be given, and suppose $m^k \equiv 0$ (mod $n$) for some positive $k \in \mathbb{Z}$. Then $n|m^k$, so there exists a $c \in \mathbb{Z}$ with $m^k = cn = c\prod_{j=1}^r p_j$.
We see that each $p_j$ divides $m^k$, so $p_j|m$ by primality. Because the $p_j$ are distinct primes, we see $\prod_{j=1}^r p_j | m$ also, that is, $n | m$. But then we have $m \equiv 0$ (mod $n$). Therefore Nil$(\mathbb{Z}/n\mathbb{Z}) = 0$ and we are done.
