Maths WorkshopMaths problems with full solutions
Exercise 2217Algebra › Rings and fieldsM1Added 3 Nov 2026

Sums of two squares via $\mathbb{Z}[i]$

#sums of squares#Gaussian integers#factorization

Statement

Using Z[i]\mathbb{Z}[i], show that a prime p≡1(mod4)p\equiv1\pmod4 is a sum of two squares.

Hint

−1-1 is a quadratic residue mod pp when p≡1(mod4)p\equiv1\pmod4 (Wilson's theorem or Euler's criterion). So p∣a2+1p\mid a^2+1 for some aa, i.e. p∣(a+i)(a−i)p\mid(a+i)(a-i) in Z[i]\mathbb{Z}[i].

Show solutionHide solution

Solution

−1-1 is a square mod pp. For p≡1(mod4)p\equiv1\pmod4, by Euler's criterion (−1)(p−1)/2=1(-1)^{(p-1)/2}=1, so there is aa with a2≡−1(modp)a^2\equiv-1\pmod p. Thus p∣a2+1=(a+i)(a−i)p\mid a^2+1=(a+i)(a-i).

pp is not irreducible in Z[i]\mathbb{Z}[i]. If pp were prime in Z[i]\mathbb{Z}[i], then p∣a+ip\mid a+i or p∣a−ip\mid a-i, which is impossible (the imaginary part is ±1\pm1, not divisible by pp).

Factorization. So p=zwp=zw with z,wz,w non-units. Taking norms: p2=N(p)=N(z)N(w)p^2=N(p)=N(z)N(w), and since z,wz,w are non-units, N(z),N(w)>1N(z),N(w)>1. So N(z)=N(w)=pN(z)=N(w)=p.

Conclusion. If z=a+biz=a+bi, then a2+b2=pa^2+b^2=p. Every prime p≡1(mod4)p\equiv1\pmod4 is a sum of two squares.