Maths WorkshopMaths problems with full solutions
Exercise 625Number theory › PrimesOlympiadAdded 4 Nov 2026

When can 2ⁿ + 1 or 2ⁿ − 1 be prime?

#factorisation#primes#Fermat primes#Mersenne primes

Statement

  1. Prove that if 2n+12^n+1 is prime (n≥1n\ge1), then nn is a power of 22.
  2. Prove that if 2n−12^n-1 is prime, then nn is prime.
Hint

Use xm−1=(x−1)(xm−1+⋯+1)x^m-1=(x-1)(x^{m-1}+\cdots+1) and, for odd mm, xm+1=(x+1)(xm−1−xm−2+⋯+1)x^m+1=(x+1)(x^{m-1}-x^{m-2}+\cdots+1).

Show solutionHide solution

Solution

1. Suppose nn is not a power of 22: n=2smn=2^s m with m≥3m\ge3 odd. Let x=22sx=2^{2^s}. Then 2n+1=xm+12^n+1=x^m+1 is divisible by x+1x+1, and 1<x+1<xm+11<x+1<x^m+1. So 2n+12^n+1 is composite. Hence nn must be a power of 22 (the numbers 22k+12^{2^k}+1 are the Fermat numbers).

2. Suppose n=abn=ab with a,b≥2a,b\ge2. Then 2n−1=(2a)b−12^n-1=(2^a)^b-1 is divisible by 2a−12^a-1, and 1<2a−1<2n−11<2^a-1<2^n-1. So 2n−12^n-1 is composite. Hence nn is prime (the numbers 2p−12^p-1 are Mersenne numbers).

Remark. The converses are false: 211−1=23⋅892^{11}-1=23\cdot89 and 232+1=641⋅67004172^{32}+1=641\cdot6700417.

Lesson. Whenever an exponent has a divisor, a geometric-sum factorisation xm±1x^m\pm1 produces a proper factor.