Sum of Two Squares
Theorem: Every prime is a sum of two squares.
Proof: Let . By Wilson's Theorem, is a square root of -1 modulo . (Alternatively, if is a primitive root of we may take .)
Thus . Therefore is not irreducible, because it does not divide either of these factors.
Or is it? We overlooked a detail: how do we know primes and irreducibles are the same thing in ?
We answer this by showing is euclidean with respect to the norm . That is, for any and nonzero, we find with and .
We find with via a geometric argument. The gaussian integers form a lattice, and lies within norm 1 of at least one of the points on this lattice, and we can take any of them to be .
Thus is euclidean and hence a UFD, so all irreducibles are prime.
Now we're sure is reducible, namely for nonunits . Taking norms gives . Since neither factor of has norm 1, we conclude that
Armed with this result, we can now easily describe the units and primes of . The units are simply , by considering elements of norm 1. As for the primes, if is a prime in then it is also prime in since in this case cannot be the sum of two squares. Also if is prime, then is also a prime.
We claim there are no other primes. To see this, let be some prime in . Then for some primes in . This implies for some prime in , and hence or . In the first case we have , and in the second, we see that is an integer of norm 1 implying that is an associate of . In the latter case, we must have otherwise it would contradict what we proved above.
We can also show that a positive integer is the sum of two squares if and only if it has the form where is squarefree and no prime factors equal to 3 modulo 4. This follows from the algebraic identity , and the fact that the existence of nontrivial solutions of implies we can find a square root of -1 modulo , which is impossible if .