The sum of one odd square and one even square is congruent to 1 mod 4, but there exist
composite numbers such as 21 that are and yet cannot be represented as sums of two squares.
Fermat's theorem on sums of two squares states that the
prime numbers that can be represented as sums of two squares are exactly 2 and the odd primes congruent to The representation of each such number is unique, up to the ordering of the two squares. By using the
Pythagorean theorem, this representation can be interpreted geometrically: the Pythagorean primes are exactly the odd prime numbers p such that there exists a
right triangle, with integer legs, whose
hypotenuse has They are also exactly the prime numbers p such that there exists a right triangle with integer sides whose hypotenuse has For, if the triangle with legs x and y has hypotenuse length \sqrt p (with x>y), then the triangle with legs x^2-y^2 and 2xy has hypotenuse Another way to understand this representation as a sum of two squares involves
Gaussian integers, the
complex numbers whose real part and imaginary part are both The norm of a Gaussian integer x+iy is the Thus, the Pythagorean primes (and 2) occur as norms of Gaussian integers, while other primes do not. Within the Gaussian integers, the Pythagorean primes are not considered to be prime numbers, because they can be factored as p=(x+iy)(x-iy). Similarly, their squares can be factored in a different way than their
integer factorization, as \begin{align} p^2&=(x+iy)^2(x-iy)^2\\ &=(x^2-y^2+2ixy)(x^2-y^2-2ixy).\\ \end{align} The real and imaginary parts of the factors in these factorizations are the leg lengths of the right triangles having the given hypotenuses. ==Quadratic residues==