Maths WorkshopMaths problems with full solutions
Exercise 1332Number theory › PrimesOlympiadAdded 5 Nov 2026

Infinitely many primes ≡ 1 (mod 4)

#infinitely many primes#order#Euclid's argument

Statement

Prove that there are infinitely many primes p≡1(mod4)p\equiv1\pmod4.

Hint

Take a prime divisor qq of (n!)2+1(n!)^2+1. What is the order of n!n! modulo qq?

Show solutionHide solution

Solution

Construction. For n≥2n\ge2 let N=(n!)2+1N=(n!)^2+1 and let qq be any prime divisor of NN.

q>nq>n. If q≤nq\le n, then q∣n!q\mid n!, so N≡1(modq)N\equiv1\pmod q, contradicting q∣Nq\mid N.

qq is odd. For n≥2n\ge2, n!n! is even, so NN is odd.

The order of x=n!x=n! modulo qq. We have x2≡−1≢1(modq)x^2\equiv-1\not\equiv1\pmod q (qq odd), and x4≡1x^4\equiv1. So the order of xx is exactly 44. By Fermat's little theorem xq−1≡1x^{q-1}\equiv1, hence 4∣q−14\mid q-1, i.e. q≡1(mod4)q\equiv1\pmod4.

Conclusion. For every n≥2n\ge2 there is a prime q≡1(mod4)q\equiv1\pmod4 with q>nq>n. So there are infinitely many.

Check. n=3n=3: 37=36+137=36+1, and 37≡1(mod4)37\equiv1\pmod4. n=4n=4: 577577 is prime.

Lesson. If x2≡−1(modq)x^2\equiv-1\pmod q, then xx has order 44 and 4∣q−14\mid q-1.