Show that $\mathbb{Z}[i]/n\mathbb{Z}[i] $ is a field if and only if $n$ is a prime number and $n\neq a^2+b^2, a,b\in\mathbb{Z}$. I have to show the following statement:

$\mathbb{Z}[i]/n\mathbb{Z}[i]$ is a field if and only if $n$ is a prime number and $n\neq a^2+b^2, a,b\in\mathbb{Z}$.



*

*Let $\mathbb{Z}[i]/n\mathbb{Z}[i]$ be a field.
Case 1: $n$ is not a prime number. Then there exists integers $s,t\in\mathbb{N}\backslash\{1\}$ such that $s\cdot t=n = 0$, but it cannot be true since $s=0\lor t=0$.
Case 2: Let $n=a^2+b^2,a,b\in\mathbb{Z}$. Then
$$0=n=a^2+b^2=(a+bi)(a-bi),\qquad a,b<n.$$
and $\mathbb{Z}[i]/n\mathbb{Z}[i]$ has no zero divisors, and it cannot be true since $\mathbb{Z}[i]/n\mathbb{Z}[i]$ is a field.
I don't know if my proof for the one side is correct.
 A: First, look at the following: 
$$\frac{\mathbb{Z}[i]}{(n)} \cong \frac{\frac{\mathbb{Z}[X]}{(X^2+1)}}{\frac{(n, X^2+1)}{(X^2+1)}} \cong \frac{\mathbb{Z}[X]}{(n, X^2+1)} \cong \frac{\mathbb{Z}/n\mathbb{Z}[X]}{(X^2+1)}. $$
Now this last ring is a field if and only if $n$ is a prime $n$ and $X^2+1$ is irreducible over $\mathbb{Z}/n\mathbb{Z}$. This means $\mathbb{Z}[i]/(n)$ is a field if and only if $n$ is prime and $-1$ is not a square in $\mathbb{Z}/n\mathbb{Z}$. So we need to show that if $n$ is prime,$-1$ is a square in $\mathbb{F}_n$ if and only if $n$ is a sum of squares. 
Let $p$ be a prime number. Suppose $p$ is a sum of squares, say $p = a^2+b^2$. Then $b$ is not a multiple of $p$, so it has an inverse in $\mathbb{F_p}$. Then, in $\mathbb{F}_p$, we have
$$(ab^{-1})^2=a^2b^{-2}=-b^2b^{-2}=-1,$$
so $-1$ is a square in $\mathbb{F}_p$.
Now suppose $-1$ is a square in $\mathbb{F}_p$. 
Then the map $\varphi: \mathbb{Z}[i] \rightarrow \mathbb{F}_p$ given by $$a+bi \mapsto a+bx$$ where $x^2=-1$ in $\mathbb{F}_p$ is a surjective ringhomomorphism. Because $\mathbb{Z}[i]$ is a PID, there is some $z \in \mathbb{Z}[i]$ such that $\ker \varphi = (z)$. Let $N$ be the norm on $\mathbb{Z}[i]$. Now $p \in (z)$, so there is some $u \in \mathbb{Z}[i]$ such that $p=uz$. Now $N(p)=N(u)N(z)$. If $N(z)=p$, we are done, because there are $a, b$ such that $z=a+bi$, so $a^2+b^2=p$. So suppose $N(z)=1$, then $z$ is a unit, so $(z)=\mathbb{Z}[i]$, contradicting the isomorphism induced by $\varphi$:
$$\frac{\mathbb{Z}[i]}{(z)} \cong \mathbb{F}_p.$$
Suppose $N(z) = p^2$. Then $u$ is a unit, so $(z)=(p)$. However, $\mathbb{Z}[i]/(p)$ contains more than $p$ elements, namely $\overline{i}, \overline{0}, ..., \overline{p-1}$ are all distinct. So the result follows.
A: For one direction we can use that a field has no zero divisors. But this will not be enough to solve the question. To do this, one usually uses the following fact:
the quotient $\mathbb{Z}[i]/(p)$ is a field if and only if the ideal $(p)$ is maximal. Since the ring $ \mathbb{Z}[i]$ is Euclidean, it is enough to show that the ideals $(p)$, where $p$ is not the sum of two squares, is prime. However, the Gaussian primes are well-known: they are precisely the rational primes $p\equiv 3\bmod 4$ and their associates, and the numbers $a+bi$ such that $a^2+b^2$ is a rational prime. Furthermore, the primes congruent $3$ modulo $4$ are never the sum of two squares, see here.
