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

Prime divisors of n² + n + 1

#order#Fermat's little theorem#primes in progressions

Statement

  1. Let pp be a prime dividing n2+n+1n^2+n+1 for some integer nn. Prove that p=3p=3 or p≡1(mod3)p\equiv1\pmod 3.
  2. Deduce that there are infinitely many primes p≡1(mod3)p\equiv1\pmod3.
Hint

n3−1=(n−1)(n2+n+1)n^3-1=(n-1)(n^2+n+1). What can you say about the multiplicative order of nn modulo pp?

Show solutionHide solution

Solution

1. Since p∣n2+n+1p\mid n^2+n+1, we have p∤np\nmid n (otherwise p∣1p\mid1), and p∣n3−1p\mid n^3-1, so n3≡1(modp)n^3\equiv1\pmod p. The order dd of nn modulo pp divides 33, so d∈{1,3}d\in\{1,3\}.

  • If d=1d=1, then n≡1n\equiv1 and 0≡n2+n+1≡3(modp)0\equiv n^2+n+1\equiv3\pmod p, so p=3p=3.
  • If d=3d=3, then by Fermat's little theorem np−1≡1n^{p-1}\equiv1, so d=3d=3 divides p−1p-1, that is p≡1(mod3)p\equiv1\pmod3.

2. Let k≥3k\ge3 and put m=k!m=k!, N=m2+m+1N=m^2+m+1. For every prime q≤kq\le k we have q∣mq\mid m, hence N≡1(modq)N\equiv1\pmod q. So every prime divisor of NN is larger than kk, in particular different from 33. By part 1 each prime divisor of NN is ≡1(mod3)\equiv1\pmod 3; and N>1N>1 has at least one. So for every kk there is a prime ≡1(mod3)\equiv1\pmod3 larger than kk.

Lesson. A prime factor of Φd(n)\Phi_d(n) (here Φ3(n)=n2+n+1\Phi_3(n)=n^2+n+1) is ≡1(modd)\equiv1\pmod d unless it divides dd: this is the standard route to "infinitely many primes ≡1(modd)\equiv1\pmod d".