
APythagorean prime is aprime number of theform. Pythagorean primes are exactly the odd prime numbers that are the sum of two squares; this characterization isFermat's theorem on sums of two squares.
Equivalently, by thePythagorean theorem, they are the odd prime numbers for which is the length of thehypotenuse of aright triangle with integer legs, and they are also the prime numbers for which itself is the hypotenuse of a primitivePythagorean triangle. For instance, the number 5 is a Pythagorean prime; is the hypotenuse of a right triangle with legs 1 and 2, and 5 itself is the hypotenuse of a right triangle with legs 3 and 4.
The first few Pythagorean primes are
ByDirichlet's theorem on arithmetic progressions, this sequence is infinite. More strongly, for each, the numbers of Pythagorean and non-Pythagorean primes up to are approximately equal. However, the number of Pythagorean primes up to is frequently somewhat smaller than the number of non-Pythagorean primes; this phenomenon is known asChebyshev's bias.[1] For example, the only values of up to 600,000 for which there are more Pythagorean than non-Pythagorean odd primes less than or equal to n are 26861and 26862.[2]
The sum of one odd square and one even square is congruent to 1 mod 4, but there existcomposite numbers such as 21 that are1 mod 4 and yet cannot be represented as sums of two squares.Fermat's theorem on sums of two squares states that theprime numbers that can be represented as sums of two squares are exactly 2 and the odd primes congruent to1 mod 4.[3] The representation of each such number is unique, up to the ordering of the two squares.[4]
By using thePythagorean theorem, this representation can be interpreted geometrically: the Pythagorean primes are exactly the odd prime numbers such that there exists aright triangle, with integer legs, whosehypotenuse haslength. They are also exactly the prime numbers such that there exists a right triangle with integer sides whose hypotenuse haslength. For, if the triangle with legs and has hypotenuse length (with), then the triangle with legs and has hypotenuselength.[5]
Another way to understand this representation as a sum of two squares involvesGaussian integers, thecomplex numbers whose real part and imaginary part are bothintegers.[6] The norm of a Gaussian integer is thenumber. 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 asSimilarly, their squares can be factored in a different way than theirinteger factorization, asThe real and imaginary parts of the factors in these factorizations are the leg lengths of the right triangles having the given hypotenuses.
The law ofquadratic reciprocity says that if and are distinct odd primes, at least one of which is Pythagorean, then is aquadratic residuemodif and only if is a quadratic residuemod; by contrast, if neither nor is Pythagorean, then is a quadratic residuemod if and only if isnot a quadratic residuemod.[4]
In thefinite field with a Pythagorean prime, the polynomial equation has two solutions. This may be expressed by saying that is a quadratic residuemod. In contrast, this equation has no solution in the finite fields where is an odd prime but is notPythagorean.[4]

For every Pythagorean prime, there exists aPaley graph with vertices, representing the numbersmodulo, with two numbers adjacent in the graph if and only if their difference is a quadratic residue. This definition produces the same adjacency relation regardless of the order in which the two numbers are subtracted to compute their difference, because of the property of Pythagorean primes that is a quadraticresidue.[7]