• | Squares (and thus integer distances) in red, and |
• | Non-unique representations (up to rotation and reflection) bolded |
In number theory, the sum of two squares theorem relates the prime decomposition of any integer n > 1 to whether it can be written as a sum of two squares, such that n = a2 + b2 for some integers a, b.[1]
An integer greater than one can be written as a sum of two squares if and only if its prime decomposition contains no factor pk, where prime and k is odd.
In writing a number as a sum of two squares, it is allowed for one of the squares to be zero, or for both of them to be equal to each other, so all squares and all doubles of squares are included in the numbers that can be represented in this way. This theorem supplements Fermat's theorem on sums of two squares which says when a prime number can be written as a sum of two squares, in that it also covers the case for composite numbers.
A number may have multiple representations as a sum of two squares, counted by the sum of squares function; for instance, every Pythagorean triple gives a second representation for beyond the trivial representation .