We call these the Gaussian integers.
Our first objective is to exhibit as a Euclidean ring. In order to do this we must
first introduce a function defined for every nonzero element in which satisfies

1. is a nonnegative integer for every

2. for every in

3. Given there exist such that
where or

Put

Condition (1) is obvious.

Condition (2) is also easy, since

which is since for are integer numbers and

Condition (3) is more complicated. So let and
Then in we get

This is the exact quotient in but what is the best we can do in The nearest
we can get is the number where is the integer nearest and the integer
nearest Note that

Now

and multiplying by we get

Put as quotient As reminder we then would have

We now compute

and see that condition (3) is satisfied.

LEMMA 3.8.1: Let be a prime integer and suppose that for some integer
relatively prime to we can find integers and such that

Then can be written as the sum of squares of two integers, that is, there exist integers
and such that

Proof: The ring of integers is a subring of Suppose that the integer
is also a prime element of Since

by Lemma 3.7.6 we have

But if then which would say that and
so that also would divide But then

from which we would conclude that contrary to assumption. Similarly
if Thus is nota prime element in
In consequence of this,

(1)

where and are in and where neither nor
is a unit in But this means that neither nor
From (1) it follows that

Thus

Therefore

so

or .

But
since is not a unit in otherwise
contrary to the fact that is not a unit in Thus the only feasibility
left is that

LEMMA 3.8.2: If is a prime number of the form then we can solve the congruence

Proof: Let

Since in this product there are an even number of terms, therefore

But so that

by Wilson's theorem.

THEOREM 3.8.2 (Fermat): If is a prime number of the form then

for some integers

Proof: By Lemma 3.8.2 there exists an such that
The can be chosen so that since we only need to use the remainder of
on division by We can restrict the size of even further, namely to satisfy
For if then satisfies
but Thus we may assume that we have an integer such that
and is a multiple of say Now

hence and so From this by Lemma 3.8.1
it follows that for some integers and