Suppose $n = p_1^{a_1} \cdots p_r^{a_r}$ where $p_i$'s are prime integers and $a_i$'s are positive integers.
(a) Show that the set of nilpotent elements in $\mathbb{Z}_n$ is $(p_1\cdots p_r)$, the ideal generated by the element $p_1\cdots p_r$.
(b) Find a necessary and sufficient condition on $n$ such that $\mathbb{Z}_n$ does not have any non-zero nilpotent elements.
My attempt:
(a) Let $x$ be a nilpotent element in $\mathbb{Z}_n$. Then $x^k = n$ for some $k > 0$.Note that $x \neq 1$. Since $\mathbb Z$ is a UFD, $x = p_1^{b_1} ... p_r^{b_r}$, where $b_i > 0$ and so $x^k = p_1^{k b_1} ... p_r^{k b_r} = p_1^{k b_1 - 1} ... p_r^{k b_r - 1}(p_1 ... p_r) \in (p_1 ... p_r)$. Hence the set of nilpotent elements is a subset of $(p_1 ... p_r)$. On the other hand, for all $x \in (p_1 ... p_r)$, $x = z_1 \cdot p_1 ... p_r \cdot z_2$ for some $z_1 = p_1^{c_1} ... p_r^{c_r}, z_2 = p_1^{d_1} ... p_r^{d_r} \in \mathbb{Z}_n$, so $x = p_1^{c_1 + d_1 +1} ... p_r^{c_r + d_r+1}$. Let k be an natural number such that $k(c_i+d_i+1) >a_i$ for all i. Then we have $x^k = p_1^{k(c_1 + d_1 +1)} ... p_r^{k(c_r + d_r+1)} = p_1^{a_1} ... p_r^{a_r}(p_1^{k(c_1 + d_1 +1)-a_1} ... p_r^{k(c_r + d_r+1)-a_r}) = 0 \in\mathbb{Z}_n$. Hence the $(p_1 ...p_r) \subseteq$ the set of nilpotent elements in $\mathbb{Z}_n$. Therefore $(p_1 ...p_r) =$ the set of nilpotent elements in $\mathbb{Z}_n$
(b) $a_i = 1$ for all $i$. If $a_i = 1$ for all i, then it is obvious then $\mathbb{Z}_n$ does not have any non-zero nilpotent elements. Now I just need to show that if $\mathbb{Z}_n$ does not have any non-zero nilpotent elements, then $a_i = 1$ for all $i$. Proof by contradiction: Suppose there exists some $a_i$ > 1. Then $p_1...p_r < n$ is non-zero a nilpotent element.