Exercise 1996Number theory › CongruencesOlympiadAdded 5 Nov 2026
Every prime ≡ 1 (mod 4) is a sum of two squares
#sum of two squares#Thue's lemma#pigeonhole#Wilson
Statement
Let be a prime with . Prove that for some positive integers .
Hint
First find with (use Wilson's theorem). Then apply the pigeonhole principle to the numbers with .
Show solutionHide solution
Solution
Step 1: is a square modulo . Let , which is even. By Wilson, . So satisfies .
Step 2: Thue's lemma. Let . Since is prime, it is not a square, so and . Consider the numbers
There are more of them than residues modulo , so two different pairs satisfy . Put , . Then , , and .
Step 3: conclusion. , so . Moreover . Hence . Neither nor is (otherwise would be a square), so with positive integers.
Check. : , ✓, and . .
Lesson. Pigeonhole on a lattice of values forces a short vector in a congruence class (Thue's lemma); combined with it produces a sum of two squares.