Unique maximal ideal and ring epimorphism kernel with prime numbers equivalence Let $A$ be a ring. Let $f: \mathbf{Z} \to A$ be a surjective ring homomorphism. Prove that $A$ has a unique maximal ideal iff there exists $n\in \mathbf{N}$ and $p\in\mathbf{N}$ a prime number such that $\ker f =(p^{n})$.
$(p^{n})$ denotes the ideal generated by $p^{n}$, I'm not sure if that's the standard notation.
We had to prove that in a recent exam and nobody could prove it. I haven't found it online neither. Thank you!

Hint By the first isomorphism theorem $A$ is isomorphic to $\mathbb Z / \mbox{Ker}(f)$.
$\Rightarrow$ Note that $\mbox{ker}(f)=(m)$ for some integer $m$. Assume by contradiction that $n$ is not a power of a prime. Since $n \neq 1$, there exist two primes $p \neq q$ which divide $m$. Show that $(p)/(m)$ and $(q)/(m)$ are maximal ideals in $\mathbb Z / \mbox{Ker}(f)$.
$\Leftarrow$: Show that $(p)/(p^n)$ is the only maximal ideal in $\mathbb Z/(p^n)$.
Second solution If you do not want to use the FIT, you can proceed as follows:
Since $\mathbb Z$ is a PID then $\mbox{ker}(f)= (m)$ for some integer $m$.
Claim $I$ is ideal in $A$ exactly when $I= f((k))$ for $k|m$.
Proof
$\Leftarrow$ follows from $f$ being surjective.
$\Rightarrow$ Let $I \subseteq A$ be any ideal. Then $f^{-1}(I)$ is an ideal in $\mathbb Z$ and hence
$$
f^{-1}(I)=(k) 
$$
for some $k |m$.
[This comes from $(m) =\mbox{ker}(f) \subseteq f^{-1}(I) =(k)].
Since $f$ is onto, you get
$$
I=f((k))
$$
Now, your problem follows immediately from the claim.
