This page covers section 3.8 (“A Particular Euclidean Ring”).

### Topics covered: 3.8

$\mathbb{Z}\left[i\right]$, the Gaussian integers, is the set of complex numbers $a+bi$ where $a,b\in \mathbb{Z}$. The proof of each result in this chapter is very clever.

**Theorem 3.8.1**: $\mathbb{Z}\left[i\right]$ is a Euclidean ring. The distance function is $d(a+bi)={a}^{2}+{b}^{2}$.**Lemma 3.8.1**: Let $c,p\in \mathbb{Z}$ with $p$ prime and $(c,p)=1$ such that there exist $x,y\in \mathbb{Z}$ with ${x}^{2}+{y}^{2}=cp$. Then there exist integers $a,b\in \mathbb{Z}$ such that $p={a}^{2}+{b}^{2}$.**Lemma 3.8.2**: If $p\in \mathbb{Z}$ is a prime of the form $4n+1$, $n$ an integer, then there exists $x\in \mathbb{Z}$ such that ${x}^{2}\equiv -1\phantom{\rule{0ex}{0ex}}\phantom{\rule{0.6666666666666666em}{0ex}}\mathrm{m}\mathrm{o}\mathrm{d}\text{\hspace{0.17em}}\text{\hspace{0.17em}}p$.**Theorem 3.8.2 (Fermat)**: If $p\in \mathbb{Z}$ is a prime of the form $4n+1$, $n$ an integer, then there exist $a,b\in \mathbb{Z}$ such that $p={a}^{2}+{b}^{2}$.

The problems below are paraphrased from/inspired by those given in Topics in Algebra by Herstein. The solutions are my own unless otherwise noted. I will generally try, in my solutions, to stick to the development in the text. This means that problems will not be solved using ideas and theorems presented further on in the book.

### Herstein 3.8.1: Find all the units in $\mathbb{Z}\left[i\right]$.

Suppose $a+bi\in \mathbb{Z}\left[i\right]$ is a unit, so there exists $r+si\in \mathbb{Z}\left[i\right]$ with $1=(a+bi)(r+si)\mathrm{.}$

We have that $1=d\left(1\right)=d(a+bi)d(r+si)$ and $d$ maps into the non-negative integers. This forces the norm of a unit to be $1$. Then we have $d(a+bi)={a}^{2}+{b}^{2}=1$, and we easily enumerate the solutions as $\pm 1,\pm i$. These are the four units of $\mathbb{Z}\left[i\right]$.

### Herstein 3.8.2: Prove that if $a+bi\in \mathbb{Z}\left[i\right]$ is non-zero and is not a unit, then ${a}^{2}+{b}^{2}>1$.

Lemma 3.7.3, states that, in a Euclidean ring, multiplication by a non-zero unit always increases the norm of an element. That is, with $r,s$ elements of Euclidean ring $R$ and $s\mathrm{\ne}0$, we have that $d\left(r\right)<d\left(rs\right)$. In particular, here we may say that $1=d\left(1\right)<d(1\cdot (a+bi\left)\right)={a}^{2}+{b}^{2}\mathrm{.}$

### Herstein 3.8.3: Find the greatest common divisor in $\mathbb{Z}\left[i\right]$ of

### (a) $3+4i$ and $4-3i$.

### (b) $11+7i$ and $18-i$.

We remark that the greatest common divisor is only unique up to association (multiplication by unit). As proven in problem 3.7.4, the prescription given there will produce greatest common divisors. Still, how does one pick out the quotients ${q}_{i}$?

**(a)** We will try to divide $4-3i$ into $3+4i$. We need to find a quotient that gives us a remainder small enough to be acceptable in the algorithm. That is, we seek ${q}_{0}$ such that $3+4i={q}_{0}(4-3i)+{r}_{1}$ with $d\left({r}_{1}\right)<d(4-3i)=25$. Drawing the two points on the complex plane gives a hint. $4-3i$ can be brought near to $3+4i$ by a rotation of $\pi \mathrm{/}2$ about the origin, which is equivalent to a multiplication by $i$. Then we take ${q}_{0}=i$.

But, oops! $i(4-3i)=3+4i$ so we are already done. Their greatest common divisor is $4-3i$ (or $3+4i$, which we have just seen is its associate).

**(b)** This time we may have a less trivial situation. Again drawing the picture on the complex plane we see that $18-i$ may be brought somewhat near to $11+7i$ if it is rotated by $\pi \mathrm{/}2$, or equivalently, multiplied by $i$. A rotation by something like $\pi \mathrm{/}6$ might be even better, but our choice should be fine. Thus we take ${q}_{0}=i$ and write
$11+7i=i(18-i)+10-11i$

so that ${r}_{1}=10-11i$. This is okay because $d\left({r}_{1}\right)=221<325=d(18-i)$. Drawing out the points $18-i$ and $10-11i$, we really think a rotation by $\pi \mathrm{/}4$ of $10-11i$ would be helpful in this case. Of course, we can’t multiply by ${e}^{i\pi \mathrm{/}4}$ because there is nothing like $\sqrt{2}$ in our ring. Taking the next best thing, we will try ${q}_{1}=1+i$. Thus, we write $18-i=(1+i)(10-11i)-3.$

Then ${r}_{2}=-3$ and $d\left({r}_{2}\right)=9<221=d\left({r}_{1}\right)$, so we have improved considerably.

Now a glance at $10-11i={q}_{2}(-3)+{r}_{3}$ suggests ${q}_{2}=-3+4i$ and therefore ${r}_{3}=1+i$. We have $d\left({r}_{3}\right)=2<9=d\left({r}_{2}\right)$. Continuing, we can write $-3=(1+i)(i-1)-1,$

which puts ${q}_{3}=i-1$ and ${r}_{4}=-1$. At last, we are done, because ${r}_{3}=-(1+i){r}_{4}$. Therefore the greatest common divisor of $11+7i$ and $18-i$ is $-1$, or equivalently $1$: they are relatively prime. We can exhibit two Gaussian integers $x,y$ such that $(11+7i)x+(18-i)y=1$. They may be found by tracing backwards all of the steps of the algorithm, whereupon we find ${r}_{4}=(1+{q}_{0}{q}_{1}+{q}_{0}{q}_{3}+{q}_{2}{q}_{3}+{q}_{0}{q}_{1}{q}_{2}{q}_{3})(18-i)-({q}_{1}+{q}_{3}+{q}_{1}{q}_{2}{q}_{3})(11+7i)\mathrm{.}$

Plugging in values, $(-6+i)\cdot (18-i)+(6-6i)\cdot (11+7i)=1.$

### Herstein 3.8.4: Let $p$ be a prime integer of the form $4k+3$ with $k\in \mathbb{Z}$. Prove that there can not be an $x\in \mathbb{Z}$ with ${x}^{2}\equiv -1\phantom{\rule{0ex}{0ex}}\phantom{\rule{0.6666666666666666em}{0ex}}\mathrm{m}\mathrm{o}\mathrm{d}\text{\hspace{0.17em}}\text{\hspace{0.17em}}p$.

Suppose that such an $x$ existed, with ${x}^{2}+1=cp$ for some $c\in \mathbb{Z}$. Then we fall into the case of Lemma 3.8.1 which says that $p$ may be expressed as a sum of two squares, $p={a}^{2}+{b}^{2}$. Looking at this equation modulo $4$, we find that it has no solutions: $p\equiv 3\phantom{\rule{0ex}{0ex}}\phantom{\rule{0.6666666666666666em}{0ex}}\mathrm{m}\mathrm{o}\mathrm{d}\text{\hspace{0.17em}}\text{\hspace{0.17em}}4$ while squares modulo $4$ can be only $0$ or $1$ so that ${a}^{2}+{b}^{2}$ can only take the values $\{0,1,2\}$. This contradiction forces us to conclude that no such $x$ may exist.

It is easy to see that the only quadratic residues modulo $4$ are $0$ and $1$. If $k\in \mathbb{Z}$ then $(2k{)}^{2}=4{k}^{2}\equiv 0\phantom{\rule{0ex}{0ex}}\phantom{\rule{0.6666666666666666em}{0ex}}\mathrm{m}\mathrm{o}\mathrm{d}\text{\hspace{0.17em}}\text{\hspace{0.17em}}4$, so even numbers will always square to zero modulo $4$. On the other hand, $(2k+1{)}^{2}=4{k}^{2}+4k+1\equiv 1\phantom{\rule{0ex}{0ex}}\phantom{\rule{0.6666666666666666em}{0ex}}\mathrm{m}\mathrm{o}\mathrm{d}\text{\hspace{0.17em}}\text{\hspace{0.17em}}4$, so odd numbers will always square to $1$ modulo $4$.

**Alternate solution**: In light of problem 3.8.5, which suggests that my method (invoking Lemma 3.8.1) is too heavy-handed, here is another solution. Fermat’s little theorem says that such an $x$ would have
${x}^{p-1}\equiv 1\phantom{\rule{0ex}{0ex}}\phantom{\rule{1em}{0ex}}\mathrm{m}\mathrm{o}\mathrm{d}\text{\hspace{0.17em}}\text{\hspace{0.17em}}p,$

where we have used the fact that $p\ue020\mid x$. Now, this may be rewritten as ${x}^{4k+2}\equiv 1\phantom{\rule{0ex}{0ex}}\phantom{\rule{1em}{0ex}}\mathrm{m}\mathrm{o}\mathrm{d}\text{\hspace{0.17em}}\text{\hspace{0.17em}}p\mathrm{.}$

On the other hand, from ${x}^{2}\equiv -1\phantom{\rule{0ex}{0ex}}\phantom{\rule{0.6666666666666666em}{0ex}}\mathrm{m}\mathrm{o}\mathrm{d}\text{\hspace{0.17em}}\text{\hspace{0.17em}}p$, we have that ${x}^{4k+2}\equiv {x}^{2(2k+1)}\equiv (-1{)}^{2k+1}\equiv -1\phantom{\rule{0ex}{0ex}}\phantom{\rule{1em}{0ex}}\mathrm{m}\mathrm{o}\mathrm{d}\text{\hspace{0.17em}}\text{\hspace{0.17em}}p,$

which is a contradiction. Hence no such $x$ exists.

### Herstein 3.8.5: Let $p$ be a prime integer of the form $4k+3$ with $k\in \mathbb{Z}$. Prove that there do not exist $a,b\in \mathbb{Z}$ with $p={a}^{2}+{b}^{2}$.

This was proven in the course of solving problem 3.8.4, where we consider the equation $p={a}^{2}+{b}^{2}$ modulo $4$.

### Herstein 3.8.6: Prove that there are infinitely many primes of the form $4k+3$ with $k\in \mathbb{Z}$.

First let us recall Euclid’s proof that there are infinitely many prime numbers. Suppose to the contrary that there was only a finite set of prime numbers, $\{{p}_{1},\dots ,{p}_{N}\}$. Then construct $P={p}_{1}\cdots {p}_{N}$ and $Q=P+1$. Because any integer can be factored into primes, we know that $Q$ has *some* prime divisor $p$. If $p$ were to belong to the supposed set, however, then we would have $p\mid Q$ and $p\mid P$, so that $p\mid (Q-P)=1$ which is not possible. Therefore $Q$ necessarily has a prime divisor which does not belong to our list, so the list is incomplete whenever it is finite. Note that $Q$ itself is not necessarily a prime (though it sometimes is), but rather that its prime divisors are all “new” — none belonged to the old list. For instance, $2\cdot 3\cdots 11\cdot 13+1=59\cdot 509$.

Now we turn to the problem of primes of the form $4k+3$. It is natural to consider things like $Q=(4{k}_{1}+3)\cdots (4{k}_{N}+3)\pm 1$

but quick numerical investigations show that these do not work. We would like to produce some $Q$ which has a “new” prime divisor of the form $4k+3$, and these do not necessarily. For instance, $3\cdot 7\cdot 11+1={2}^{3}\cdot 29$ and $29\equiv 1\phantom{\rule{0ex}{0ex}}\phantom{\rule{0.6666666666666666em}{0ex}}\mathrm{m}\mathrm{o}\mathrm{d}\text{\hspace{0.17em}}\text{\hspace{0.17em}}4$. Similarly, $3\cdot 7-1={2}^{2}\cdot 5$. Perhaps the plus and minus $1$ cases can switch off, each providing a new prime in its turn… but no, $3\cdot 7\cdot 11\cdot 19\cdot 23+1={2}^{2}\cdot 25237$

(with $25237\equiv 1\phantom{\rule{0ex}{0ex}}\phantom{\rule{0.6666666666666666em}{0ex}}\mathrm{m}\mathrm{o}\mathrm{d}\text{\hspace{0.17em}}\text{\hspace{0.17em}}4$) while $3\cdot 7\cdot 11\cdot 19\cdot 23-1=2\cdot 17\cdot 2969$

(with $2969\equiv 1\phantom{\rule{0ex}{0ex}}\phantom{\rule{0.6666666666666666em}{0ex}}\mathrm{m}\mathrm{o}\mathrm{d}\text{\hspace{0.17em}}\text{\hspace{0.17em}}4$).

Sticking to this general Euclidean train of logic, we might hope that there is *some* sort of $Q$ that is useful in this argument. We want a $Q$ which grants us a prime divisor of the form $4k+3$, so somehow it must be impossible for all the prime divisors be of the form $4k+1$ (if we can avoid divisibility by $2$, all the better). Were it to be the case that all the prime divisors of $Q$ had the form $4k+1$, then
$Q=(4{k}_{1}+1)\cdots (4{k}_{M}+1)=4(\dots )+1,$

i.e. $Q$ must be of the form $4K+1$. We can choose a form for $Q$ which explicitly forbids this possibility. If we enumerate the, assumedly finite, set of $4k+3$ primes as $\{{p}_{1},\dots ,{p}_{N}\}$, with ${p}_{1}=3$, ${p}_{2}=7$, ${p}_{3}=11$, …, then we may try $Q=4{p}_{1}\cdots {p}_{N}+3.$

If we take $Q$ in this form, then it has two beneficial features: (1) $Q$ is odd, so $2\nmid Q$, and (2) $Q\equiv 3\phantom{\rule{0ex}{0ex}}\phantom{\rule{0.6666666666666666em}{0ex}}\mathrm{m}\mathrm{o}\mathrm{d}\text{\hspace{0.17em}}\text{\hspace{0.17em}}4$, so not all prime divisors of $Q$ may be of the form $4k+1$.

Therefore $Q$ looks like what we need, but does it actually provide us with new $4k+3$ primes when we factor it? Well… no. $4{p}_{1}+3=3\cdot 5$, so it gives us nothing new there: it repeats $3$ from the list and $5$ is not of the $4k+3$ form. Will it happen in general that a prime divisor $Q$ will be repeated from the list? Suppose $p$ is a $4k+3$ prime which divides $Q$ but also belongs to the finite list. Then $p\mid (Q-4{p}_{1}\cdots {p}_{N})=3,$

which means that this can only happen if the prime in question is $3$. Still, that is enough to destroy the argument, because we do not necessarily produce a new $4k+3$ prime. There is a way out, which is to just skip $3$ in the product of the known-prime set. In that case, we will never get $3\mid Q$ because if $Q=4{p}_{2}\cdots {p}_{N}+3,$

then a prime $p$ dividing $Q$ must also divide $Q-3=4{p}_{2}\cdots {p}_{N}$. We have omitted $3$ from the product, though, so $p$ cannot be $3$. This, therefore, is the desired form for $Q$.

**Summing up**: Suppose there are only finitely many primes of the form $4k+3$, and enumerate them as $\{{p}_{1},\dots ,{p}_{N}\}$ where ${p}_{1}=3$, ${p}_{2}=7$, ${p}_{3}=11$, and so on. Consider the quantity
$Q=4{p}_{2}\cdots {p}_{N}+3,$

where we intentionally omit ${p}_{1}$ from the product. We see that $Q$ is odd, so that $2\nmid Q$ and all prime divisors of $Q$ must be of the form $4k+1$ or $4k+3$ for some integer $k$. It is impossible that *all* of the prime divisors of $Q$ be of the form $4k+1$, because their product would be $1$ modulo $4$, whereas $Q$ is clearly $3$ modulo $4$. Hence there exists a prime divisor $p\mid Q$ with $p\equiv 3\phantom{\rule{0ex}{0ex}}\phantom{\rule{0.6666666666666666em}{0ex}}\mathrm{m}\mathrm{o}\mathrm{d}\text{\hspace{0.17em}}\text{\hspace{0.17em}}4$. Suppose that $p$ also belongs to the set $\{{p}_{1},\dots ,{p}_{N}\}$, then we must have
$p\mid (Q-4{p}_{2}\cdots {p}_{N})=3,$

i.e. $p=3$. This is impossible, because if $3\mid Q$, then $3\mid (Q-3)=4{p}_{2}\cdots {p}_{N}$ which we know to be false (we purposely omitted ${p}_{1}=3$ for just this purpose). Hence $p$ does not belong to the list of “known” $4k+3$ primes, so it is a new one and the finite list is incomplete. Therefore there are infinitely many primes of the form $4k+3$, $k\in \mathbb{Z}$.

### Herstein 3.8.7*: Prove that there are infinitely many primes of the form $4k+1$ with $k\in \mathbb{Z}$.

We have a couple of results from the chapter on primes of the form $4k+1$. For instance, we know from Lemma 3.8.2 that if $p$ is a prime of the form $4k+1$, then there exists $x\in \mathbb{Z}$ with ${x}^{2}\equiv -1\phantom{\rule{0ex}{0ex}}\phantom{\rule{0.6666666666666666em}{0ex}}\mathrm{m}\mathrm{o}\mathrm{d}\text{\hspace{0.17em}}\text{\hspace{0.17em}}p$. On the other hand, in problem 3.8.4 we showed that this is not true for primes of the form $4k+3$. Of course, all odd primes fall into one of the two classes, so for $p>2$ prime, $p$ has the form $4k+1$ if and only if there is a solution $x$ to ${x}^{2}\equiv -1\phantom{\rule{0ex}{0ex}}\phantom{\rule{0.6666666666666666em}{0ex}}\mathrm{m}\mathrm{o}\mathrm{d}\text{\hspace{0.17em}}\text{\hspace{0.17em}}p$.

We would like to make use of the Euclidean approach again, somehow exploiting the property just described. One way to do this is to suppose there are only finitely many $4k+1$ primes, say $\{{p}_{1},\dots ,{p}_{N}\}$ with ${p}_{1}=5$, ${p}_{2}=13$, etc., and to construct $Q=({p}_{1}\cdots {p}_{N}{)}^{2}+1.$

We note immediately that $Q$ is even, so it will always have a factor of $2$ which is not of interest to us. Of course, $Q$ is larger than two, so it will also have odd prime divisors. Let $p$ be an odd prime divisor of $Q$. Working in the same way as before, we say that $p$ may not belong to the old list, because if it did then $p\mid (Q-({p}_{1}\cdots {p}_{N}{)}^{2})=1,$

which is no good. Therefore $p$ is an odd prime which does not belong to the list. Moreover, we see that $x={p}_{1}\cdots {p}_{N}$ is an integer such that ${x}^{2}=Q-1\equiv -1\phantom{\rule{0ex}{0ex}}\phantom{\rule{1em}{0ex}}\mathrm{m}\mathrm{o}\mathrm{d}\text{\hspace{0.17em}}\text{\hspace{0.17em}}p,$

so that $p$ must be of the form $4k+1$. Thus we have exhibited a new $4k+1$ prime and there must be infinitely many.

### Herstein 3.8.8*: Determine all of the prime elements in $\mathbb{Z}\left[i\right]$.

A prime element $p\in \mathbb{Z}\left[i\right]$ is one such that if $a,b\in \mathbb{Z}\left[i\right]$ satisfy $p=ab$, then one of $a$ or $b$ is a unit. We showed in problem 3.8.1 that the units of $\mathbb{Z}\left[i\right]$ are $\pm 1$ and $\pm i$. We may restrict attention to the first quadrant of the complex plane (including the positive real axis), because Gaussian integers in the other quadrants are all associates of Gaussian integers in the restricted set.

First consider the elements of $\mathbb{Z}$. Of course, if $n$ is composite in $\mathbb{Z}$, then it is still composite in $\mathbb{Z}\left[i\right]$. Turning to prime integers, we have that $2=(1+i)(1-i),$

so $2$ is not prime in $\mathbb{Z}\left[i\right]$. Similarly, if $k\in \mathbb{Z}$ and $p=4k+1$ is a prime in $\mathbb{Z}$, then by Theorem 3.8.2 there exist $a,b\in \mathbb{Z}$ such that $p={a}^{2}+{b}^{2}$. Then we have $p=(a+bi)(a-bi)$ and so $4k+1$ primes are composite in $\mathbb{Z}\left[i\right]$. On the other hand, $4k+3$ primes are prime in $\mathbb{Z}\left[i\right]$: Suppose that $k\in \mathbb{Z}$ and $p=4k+3$ is a prime in $\mathbb{Z}$ but that it factors as $p=(a+bi)(c+di)$

in $\mathbb{Z}\left[i\right]$. Then, considering the norm of the equation, we have ${p}^{2}=({a}^{2}+{b}^{2})({c}^{2}+{d}^{2})$

which gives three possibilities for the value of ${a}^{2}+{b}^{2}$. If ${a}^{2}+{b}^{2}=1$, then $a+bi$ is a unit; if ${a}^{2}+{b}^{2}={p}^{2}$, then ${c}^{2}+{d}^{2}=1$ so $c+di$ is a unit. Otherwise ${a}^{2}+{b}^{2}=p$, but we know from problem 3.8.5 that this is impossible because $p\equiv 3\phantom{\rule{0ex}{0ex}}\phantom{\rule{0.6666666666666666em}{0ex}}\mathrm{m}\mathrm{o}\mathrm{d}\text{\hspace{0.17em}}\text{\hspace{0.17em}}4$. Therefore one of $a+bi$ or $c+di$ is a unit, so a $4k+3$ prime is again prime in the Gaussian integers. Of course, $-p$, $ip$ and $-ip$ are Gaussian primes as well.

Now we consider the primality of $a+bi$ with $a,b>0$. It’s not immediately clear what the condition should be, although it is pretty clear that primes of this type exist — for instance, $1+i$ is of such small norm that we can easily see it is prime. Consider a factorization $a+bi=(r+si)(t+ui)$ whose norm gives ${a}^{2}+{b}^{2}=({r}^{2}+{s}^{2})({t}^{2}+{u}^{2})\mathrm{.}$

One case jumping out at us here is that where ${a}^{2}+{b}^{2}$ is prime. If ${a}^{2}+{b}^{2}$ is prime, then one of the factors must be a unit because it will have a norm of $1$. In other words, if the norm of $a+bi$ is prime in $\mathbb{Z}$, then $a+bi$ is prime in $\mathbb{Z}\left[i\right]$ (we still require $a,b>0$). Playing around with Gaussian integers (and Mathematica’s handy ability to factor them and check their primality), one can easily be convinced that this condition is not only sufficient but also necessary.

The conjecture is then: if $a,b>0$, then $a+bi$ is prime in $\mathbb{Z}\left[i\right]$ if and only if ${a}^{2}+{b}^{2}$ is prime in $\mathbb{Z}$. Half of this result was proven in the preceding paragraph. We now seek to prove that if $a+bi$ is prime in $\mathbb{Z}\left[i\right]$, then ${a}^{2}+{b}^{2}$ is a prime integer. We have $(a+bi)(a-bi)={a}^{2}+{b}^{2}={p}_{1}\cdots {p}_{N},$

where we have factored ${a}^{2}+{b}^{2}$ into primes in $\mathbb{Z}$. By Lemma 3.7.6, there is a prime $p\in \{{p}_{1},\dots ,{p}_{N}\}$ with $(a+bi)\mid p$. Notice that we must be very careful here. It is tempting to say the opposite, that one of the $p$’s must divide $(a+bi)$, but this is not true because $p$ may not be prime in $\mathbb{Z}\left[i\right]$. Carrying on, we have that $(a+bi)\mid p$, so there are $x,y\in \mathbb{Z}$ with $(a+bi)(x+yi)=p\mathrm{.}$

Taking the complex conjugate, we also see that $(a-bi)\mid p$. Therefore ${a}^{2}+{b}^{2}=(a+bi)(a-bi)\mid {p}^{2}$

which forces ${a}^{2}+{b}^{2}=1$, $p$ or ${p}^{2}$. The condition $a,b>0$ forbids the first choice. If ${a}^{2}+{b}^{2}={p}^{2}$, then we can consider $p\cdot p=(a+bi)(x+yi)(a-bi)(x-yi)={p}^{2}({x}^{2}+{y}^{2})$

which forces $x+yi$ to be a unit. In that case, $(a+bi)(x+yi)=p$ forces $a+bi$ to lie along an axis, contradicting the supposition that $a,b>0$. Therefore ${a}^{2}+{b}^{2}\mathrm{\ne}{p}^{2}$ and we are left with the conclusion that ${a}^{2}+{b}^{2}$ is a prime.

**Summing up**: We have restricted attention to the first quadrant and the positive real axis, all the while understanding that the results in that quadrant will be mirrored to the other three quadrants (because they are related to the first by multiplication by the units $i$, ${i}^{2}$, ${i}^{3}$). The general conditions resulting from the analysis may be stated:

The Gaussian integer $a+bi$ is prime if and only if

- $ab=0$ and $a+b$ is a $4k+3$ prime (i.e. a $4k+3$ prime along any axis), or
- $ab\mathrm{\ne}0$ and ${a}^{2}+{b}^{2}$ is prime in $\mathbb{Z}$ (so it can be $2$ or a $4k+1$ prime).

### Herstein 3.8.9*: Which positive integers can be written as a sum of two squares?

Let $a,x,y\in \mathbb{Z}$ be such that $a={x}^{2}+{y}^{2}$. We can then consider the Gaussian integer $x+yi$ which has norm equal to $a$. By Theorem 3.7.2 (Euclidean rings are unique factorization domains), we can factor $x+yi$ as a product of Gaussian primes $\left\{{\pi}_{i}\right\}$, $x+yi={\pi}_{1}\cdots {\pi}_{N}\mathrm{.}$

Now, having classified the primes in problem 3.8.8, we can say that each ${\pi}_{i}$ can have a norm equal to either $2$, a $4k+1$ prime, or to the square of a $4k+3$ prime. Therefore, the integer $a$ will be some product of twos, $4k+1$ primes and squares of $4k+3$ primes. Of course, $a$ always has a prime factorization, so the only true restriction here is that the $4k+3$ primes must come in as even powers. Now we have seen that any $a$ expressible as a sum of two squares can be written in this form, but we still would like to show that every such product gives rise to something like $a$.

Let $\{{p}_{1},\dots ,{p}_{M}\}$ be a collection of twos and $4k+1$ primes and let $\{{q}_{1},\dots ,{q}_{N}\}$ be a collection of $4k+3$ primes. The integer $A={p}_{1}\cdots {p}_{M}{q}_{1}^{2}\cdots {q}_{N}^{2}$

can easily be translated into the norm of a certain Gaussian integer: for each ${p}_{i}$, there exist ${r}_{i},{s}_{i}\in \mathbb{Z}$ with ${p}_{i}={r}_{i}^{2}+{s}_{i}^{2}$, so consider $z=({r}_{1}+i{s}_{1})\cdots ({r}_{M}+i{s}_{M}){q}_{1}\cdots {q}_{N}\mathrm{.}$

We have that the norm of $z$ is $A$, so that $A$ is expressible as the sum of two squares.

Therefore, the positive integers expressible as a sum of two squares are exactly those for which $4k+3$ primes come into the prime factorization with only even powers.