Learn/Number Theory/Sums of Two Squares
Number Theory • Topic 27

Sums of Two Squares

Which integers can be written as the sum of two squares ()? This classic problem links arithmetic to the geometry of the Gaussian integers.

Fermat's Theorem on Sums of Two Squares

Theorem (Fermat's Theorem)
An odd prime can be written as if and only if:
  • Primes (like 3, 7, 11) cannot be written as sums of two squares.
  • The prime 2 can be written as .

General Integers

Using the Brahmagupta–Fibonacci identity:
The product of sums of two squares is a sum of two squares.
Theorem (Sum of Two Squares Condition)
A positive integer can be written as a sum of two squares if and only if in the prime factorization of , every prime of the form occurs to an even power.
Example
.
  • Prime 3 ( form) has exponent 2 (even).
  • Prime 5 ( form) has exponent 1.
  • Yes, 45 is a sum of two squares ().

Practice Problems

Exercise (Problem 1)
Express and as sums of two squares.
Exercise (Problem 2)
Determine if can be written as a sum of two squares.
Exercise (Problem 3)
Prove that no integer of the form can be a sum of two squares.