Some primes are a sum of two squares, others never can be — which is which?
5 = 1² + 2², 13 = 2² + 3², 17 = 1² + 4² — but try as you might, you'll never write 7, 11, 19 or 23 as a sum of two whole-number squares. Among odd primes, what simple rule separates the ones that can always be split into two squares from the ones that never can?
Reveal the answer
A prime equals a sum of two squares if and only if it leaves a remainder of 1 when divided by 4 (or is 2 itself). Primes leaving remainder 3 (like 7, 11, 19, 23) can never be written as a sum of two squares, since squares themselves only ever leave remainder 0 or 1 mod 4. Fermat stated this in a 1640 letter without publishing his proof; the first published proof came from Euler almost a century later, in 1747.