Let $F$ a field ed $f\colon\mathbb{Z}\to F$ an onto morphism. We know that $\ker f$ is an ideal of $\mathbb{Z}$, then $\ker f=(n)=n\mathbb{Z}$ for same $n\in\mathbb{Z}$. For the first isomorphism theorem we have that $$\mathbb{Z}_n:=\mathbb{Z}/n\mathbb{Z}=\mathbb{Z}/\ker f\cong F.$$
Now, if $n=0$, the canonical projection is $\pi\colon\mathbb{Z}\to \mathbb{Z}$, but the only non-zero morphism from $\mathbb{Z}$ to $\mathbb{Z}$ is $id_{\mathbb{Z}}$ which is, in particular, injective. Since $\ker f=n\mathbb{Z}$, then $\tilde{f}\colon\mathbb{Z}\to F$ is injective, but for the first isomorphism theorem $f=\tilde{f}\circ\pi$, then $f$ is injective, moreover, for hypotesis, $f$ is onto, then $f$ is an isomorphism. But this is absurd, because $\mathbb{Z}$ is not a field. Therefore $n$ can not be $0$.
On the other hand $\mathbb{Z}_n\cong F$, then $\mathbb{Z}_n$ is a field, then $n$ must be prime.
Correct?
Thanks!
We can assume $\ker(f)\neq (0)$, since this would imply that $\Bbb Z$ is a field.
Since $\Bbb Z$ is a PID, we can assume $\ker(f)=(n)$, where $n\in\Bbb Z^+$. You are ofcourse right that $\Bbb Z_n$ is a field $\iff n$ prime. One way to show this:
Suppose $n=ab$ so that $\ker(f)=(ab)$, then $f(ab)=f(a)f(b)=0$ in $F$. Since $F$ is a field, and so an integral domain we need to have $f(a)=0$ or $f(b)=0$, which forces either $a,b$ to be a unit. This means by definition that $n$ is prime.