Mathematics
Sums of Squares and the Two-Square Theorem
Quick fact
A prime number p can be written as a sum of two squares if and only if p = 2 or p ≡ 1 (mod 4); no prime that is 3 mod 4 can ever be expressed that way.
Why this is interesting
You know that 25 = 16 + 9, so it's a sum of two squares. But why can't 6 be written that way? And is there a quick, foolproof way to tell which numbers can?
Read the full explanation
Understanding Sums of Squares and the Two-Square Theorem
Start with the simple observation that squares are whole numbers multiplied by themselves: 0, 1, 4, 9, 16, ... Now ask: which integers can be written as the sum of two such squares? For example, 1 = 1+0, 5 = 4+1, 25 = 16+9, but 3, 6, and 7 cannot be written in this way. Why? The first clue comes from looking at squares modulo 4. A square is either 0 or 1 mod 4 (because even squares are 0 mod 4 and odd squares are 1 mod 4). So a sum of two squares can only be 0, 1, or 2 mod 4, but never 3 mod 4. That instantly rules out numbers like 3, 7, and 11. But that's only a necessary condition—many numbers that are 0, 1, or 2 mod 4 still can't be written as sums of two squares, such as 6. To get a complete answer, we need to look at the prime factorization of the number.
A deeper explanation
The full answer is the two-square theorem (often attributed to Fermat). It states that a positive integer n can be expressed as a sum of two squares if and only if in its prime factorization, every prime that is congruent to 3 modulo 4 appears with an even exponent. In other words, primes of the form 4k+3 must occur in pairs. Why does this work? The key is the multiplicative property of sums of squares. This identity shows that if you can write each factor as a sum of two squares, then you can write the product as one: (a²+b²)(c²+d²) = (ac−bd)² + (ad+bc)². This identity is a manifestation of complex number multiplication: (a+bi)(c+di) = (ac−bd) + (ad+bc)i, where the norm is a²+b². Now, the primes that are 3 mod 4, like 3, 7, and 11, can never themselves be written as a sum of two squares (as we saw from the mod 4 argument). However, their squares can: for instance, 3² = 9 = 9+0, and 3⁴ = 81 = 81+0. So an even exponent allows the prime to be 'split' into a sum of two squares of its power. On the other hand, primes that are 1 mod 4, such as 5 and 13, can each be written as a sum of two squares: 5 = 1+4, 13 = 4+9. And the number 2 is just 1+1. The theorem builds on these facts, using the multiplicative identity to combine the representations of the prime factors. This neat classification turns a visual puzzle into a precise number-theoretic statement, and it opens the door to a beautiful theory of quadratic forms and Gaussian integers.