Number Theory

Fermat's Last Theorem

aⁿ + bⁿ = cⁿ has no positive-integer solutions for n > 2 — and the margin was lying

Wiles proved this 357-year-old conjecture using elliptic curves. Pierre de Fermat wrote it in the margin of Diophantus's Arithmetica around 1637 with the note that he had a "truly marvelous proof" the margin was too narrow to contain. He died in 1665 and the proof never surfaced. For three and a half centuries every elementary attack failed. Andrew Wiles announced a proof on June 23, 1993; reviewers found a critical gap that autumn; Wiles and his former student Richard Taylor fixed it in October 1994 and published in 1995. The proof works by establishing a major case of the modularity theorem and then invoking Frey's elliptic curve and Ribet's theorem.

  • StatementNo positive integers a, b, c with aⁿ + bⁿ = cⁿ for n > 2
  • ConjecturedFermat 1637 — margin of Diophantus's Arithmetica
  • ProvedWiles 1994 (with Taylor) — published Annals of Math 1995
  • StrategyModularity theorem for semistable elliptic curves + Frey curve + Ribet's theorem
  • Pre-Wiles casesn=4 (Fermat), n=3 (Euler 1770), n=5 (1825), n=7 (Lamé 1839), regular primes (Kummer 1850)
  • AwardsWolfskehl Prize 1997, Wolf Prize, Abel Prize 2016

Watch the 60-second explainer

A condensed visual walkthrough — narrated, captioned, under a minute.

Statement of the theorem

For every integer n > 2, the equation

aⁿ + bⁿ = cⁿ

has no solutions in positive integers a, b, c. The exponent n = 2 is the only case with solutions — infinitely many, in fact, given by Pythagorean triples (3, 4, 5), (5, 12, 13), (8, 15, 17), (7, 24, 25), …

Quick exhaustive search for n = 3 — try every (a, b) with 1 ≤ a, b ≤ 50:

a³ + b³ = c³  for c integer?
1³ + 1³ = 2    not a cube
1³ + 2³ = 9    not a cube
2³ + 3³ = 35   not a cube
3³ + 4³ = 91   not a cube
…
no matches found, ever, for n ≥ 3 at any size.

It is enough to prove the theorem for n = 4 and for every odd prime n = p ≥ 3. Reason: if aⁿ + bⁿ = cⁿ for composite n = km, then (a^k)^m + (b^k)^m = (c^k)^m, so a solution at exponent n forces one at every prime divisor of n.

The 357-year story

1637. Fermat reads Diophantus's Arithmetica (Bachet's 1621 Latin edition) and writes in the margin next to Problem II.8 ("split a square into two squares"): Cubum autem in duos cubos … nullam in infinitum ultra quadratum potestatem in duos eiusdem nominis fas est dividere. Cuius rei demonstrationem mirabilem sane detexi. Hanc marginis exiguitas non caperet. ("It is impossible to separate a cube into two cubes, or a fourth power into two fourth powers, or in general any power higher than the second into two powers of the same kind. I have discovered a truly marvelous proof which this margin is too narrow to contain.")

1670. Fermat's son Samuel publishes the marginal notes posthumously. The Last Theorem is in print.

~1640. Fermat proves the n = 4 case using "infinite descent," his own technique. The proof survives.

1770. Euler proves n = 3 (with a small gap involving Z[ζ_3] which Legendre and Gauss later filled).

1825. Dirichlet and Legendre independently prove n = 5.

1839. Lamé proves n = 7.

1850. Kummer uses ideal theory in cyclotomic fields to prove FLT for all "regular primes" — primes p such that p does not divide the class number of Q(ζ_p). This handles every prime below 100 except 37, 59, 67. Kummer's irregular primes 37, 59, 67 are handled separately.

1908. Paul Wolfskehl bequeaths 100,000 Marks for a proof — the Wolfskehl Prize. Crackpot submissions flood mathematics departments for the next 90 years.

1955. Yutaka Taniyama conjectures every elliptic curve over Q is associated with a modular form. André Weil and Goro Shimura refine the conjecture in the 1960s — Taniyama–Shimura–Weil.

1984. Gerhard Frey publishes a startling observation: if a^p + b^p = c^p with p prime ≥ 5, the elliptic curve E_F: y² = x(x − a^p)(x + b^p) would have such extraordinary properties that it cannot be modular. So Taniyama–Shimura would imply FLT.

1986. Ken Ribet proves Serre's epsilon conjecture, which makes Frey's link rigorous: a non-modular semistable elliptic curve with the right level structure would imply a contradiction in the theory of modular forms.

1986–1993. Andrew Wiles works in near-total secrecy from his Princeton attic on the modularity conjecture for semistable elliptic curves.

June 23, 1993. Wiles delivers the third of three lectures at the Newton Institute, Cambridge. Slide 21 quietly states modularity, then he adds: "This implies Fermat's Last Theorem. I think I'll stop here." Applause. The story breaks on the front page of The New York Times.

Autumn 1993. Nick Katz, refereeing the manuscript, finds a critical gap in the Euler system argument.

Sept–Oct 1994. Wiles and his former student Richard Taylor switch to a Kolyvagin–Flach approach combined with Hecke-algebra methods. October 1994 the gap closes.

1995. Two papers appear in Annals of Mathematics: Wiles, "Modular elliptic curves and Fermat's Last Theorem" (109 pages); Taylor–Wiles, "Ring-theoretic properties of certain Hecke algebras" (24 pages). FLT is officially proved.

1999. Breuil, Conrad, Diamond, Taylor extend modularity to all elliptic curves over Q — completing Taniyama–Shimura–Weil.

2016. Wiles receives the Abel Prize, the field's most prestigious lifetime honour, citing FLT and modularity.

Outline of the proof

  1. Suppose FLT fails. There exist positive integers a, b, c and a prime p ≥ 5 with a^p + b^p = c^p. (The n = 3, 4 cases are already proved.) Without loss assume gcd(a, b, c) = 1.
  2. Construct the Frey curve. Define the elliptic curve E_F: y² = x(x − a^p)(x + b^p) over Q. Its discriminant is (abc)^(2p), unusually rich in p-th powers.
  3. Ribet's theorem (1986). If E_F were modular, the level-lowering theorem (Ribet) would force a modular form of level 2 to exist. But there are no cusp forms of level 2 and weight 2. Contradiction. So E_F is not modular.
  4. Wiles's modularity theorem (1994). Every semistable elliptic curve over Q is modular. The Frey curve E_F is semistable.
  5. Contradiction. Steps 3 and 4 together say E_F is both modular and not modular — impossible. The assumption that FLT fails must be wrong.

Wiles's contribution — step 4 — fills 109 dense Annals pages: deformation theory of Galois representations, the R = T theorem identifying a universal deformation ring with a Hecke algebra, and meticulous case analysis depending on the residual mod-p representation. The Taylor–Wiles trick uses auxiliary primes to bootstrap the R = T identification when the original Euler-system approach fails.

Why FLT matters beyond itself

  • Modularity theorem. The chief by-product. Wiles's proof handled semistable curves; Breuil–Conrad–Diamond–Taylor (2001) extended to all elliptic curves over Q. This is now the foundational result in arithmetic geometry — every later L-function identity in the area is built on it.
  • Langlands program. Modularity is a special case of the Langlands correspondence between Galois representations and automorphic forms. FLT is the test problem that drove the development of the techniques used across the program.
  • R = T methodology. Wiles's identification of a deformation ring with a Hecke algebra is now standard practice. Applications include the Sato–Tate conjecture (proved 2008, Clozel–Harris–Shepherd-Barron–Taylor) and Serre's modularity conjecture (Khare–Wintenberger 2009).
  • Diophantine geometry. Faltings's 1983 theorem (Mordell conjecture) showed any curve of genus ≥ 2 has only finitely many rational points; the curves x^n + y^n = 1 for n ≥ 4 fall into this class. FLT strengthens "finitely many" to "exactly the trivial ones."
  • Public mathematics. Wiles's proof became one of the most-publicised mathematical events of the 20th century. Simon Singh's book (1997) and the Horizon documentary (1996) brought the story to millions.
  • Computer-checked proofs. FLT's proof spawned formal verification efforts; Lean 4 and Coq projects have formalised parts of the modularity proof, with an ongoing community goal to formalise the entire chain.

Variants and generalisations

  • Beal conjecture (1993). If A^x + B^y = C^z with gcd(A, B, C) = 1 and x, y, z ≥ 3, then A, B, C share a common prime factor. Open. $1M prize from Andrew Beal.
  • Fermat–Catalan conjecture. A^p + B^q = C^r with 1/p + 1/q + 1/r < 1 has finitely many primitive solutions. 10 known. Open in general.
  • ABC conjecture (Oesterlé–Masser 1985). Implies FLT for all sufficiently large n by a clean inequality on radicals. Mochizuki claims a proof (2012) — controversial and not generally accepted.
  • Asymptotic FLT. Proved for large exponents by various methods before Wiles — e.g. Adleman–Heath-Brown 1985 showed the first case (gcd(abc, p) = 1) holds for infinitely many p.
  • FLT over number fields. The equation a^n + b^n = c^n over rings of integers in number fields. Solutions can exist — over Q(√−7), Cohn found 2³ + (−1)³ = (√−7)³·… style identities. The "FLT for Q" is the original.
  • Faltings's theorem (1983). Every smooth projective curve of genus ≥ 2 over Q has finitely many rational points. The Fermat curve x^n + y^n = 1 has genus (n−1)(n−2)/2 ≥ 2 for n ≥ 4, so Faltings gives finiteness; FLT gives the count = 0 non-trivial.

JavaScript — exhaustive search confirms no small solutions

// Verify Fermat's Last Theorem for small n and small (a, b)
function searchFermat(n, limit) {
  const hits = [];
  for (let a = 1; a <= limit; a++) {
    for (let b = a; b <= limit; b++) {            // b >= a avoids duplicates
      const sum = Math.pow(a, n) + Math.pow(b, n);
      const c = Math.round(Math.pow(sum, 1 / n));
      if (Math.pow(c, n) === sum && c > b) {
        hits.push([a, b, c]);
      }
    }
  }
  return hits;
}

// n = 2: Pythagorean triples — infinitely many
console.log(searchFermat(2, 30).slice(0, 5));
// [[3, 4, 5], [5, 12, 13], [6, 8, 10], [7, 24, 25], [8, 15, 17]]

// n = 3: none
console.log(searchFermat(3, 100));   // []
console.log(searchFermat(3, 1000));  // [] — bigger limit, still empty

// n = 4, 5, 6: none
console.log(searchFermat(4, 200));   // []
console.log(searchFermat(5, 100));   // []
console.log(searchFermat(6, 60));    // []

// Pythagorean parametrisation: m > n > 0 generates ALL primitive triples
function pythagoreanTriple(m, n) {
  return [m*m - n*n, 2*m*n, m*m + n*n];
}
console.log(pythagoreanTriple(2, 1));   // [3, 4, 5]
console.log(pythagoreanTriple(3, 2));   // [5, 12, 13]
console.log(pythagoreanTriple(4, 1));   // [15, 8, 17]

// The Pythagorean parametrisation exists because x² + y² = 1 is a rational curve
// (genus 0). For n >= 3 the curve xⁿ + yⁿ = 1 has positive genus — no rational
// parametrisation, and by Wiles, no non-trivial rational points either.

Common misconceptions

  • "Fermat had a proof we just haven't found." Almost certainly false. The proof Wiles found uses mathematics from 1950–1990 (modular forms, elliptic curves, Galois representations). Fermat had none of it. Fermat's "marvellous proof" was almost surely flawed; he later proved n = 4 by infinite descent but never repeated the general claim.
  • "FLT is purely number theory." The proof uses complex analysis, algebraic geometry, representation theory, and the deep arithmetic of modular forms. The "number theory" framing is misleading — it's a problem solved by importing all of modern arithmetic geometry.
  • "FLT is about a, b, c arbitrary." Standard requires positive integers. The equation aⁿ + bⁿ = cⁿ has trivial solutions if we allow a = 0 or negative numbers (e.g. 1ⁿ + 0ⁿ = 1ⁿ, or in some interpretations 1³ + (−1)³ = 0³, depending on conventions). FLT excludes these by requiring a, b, c > 0.
  • "Wiles proved Taniyama–Shimura entirely." Wiles handled the semistable case (sufficient for FLT). The full Taniyama–Shimura–Weil (every elliptic curve over Q is modular) was completed by Breuil, Conrad, Diamond, and Taylor in 1999–2001.
  • "The proof is 109 pages." Plus the companion Taylor–Wiles paper, plus Ribet's level-lowering theorem (~70 pages), plus the modular forms theory (centuries of work). The full chain is tens of thousands of pages.
  • "FLT has practical applications." Not directly. The methods developed for FLT (modularity, Galois representations) have applications in cryptography (elliptic curve crypto), error-correcting codes, and theoretical physics. The theorem itself is celebrated for its proof, not its uses.

Frequently asked questions

What does Fermat's last theorem state, exactly?

For any integer n > 2, there are no positive integers a, b, c satisfying aⁿ + bⁿ = cⁿ. The case n = 2 has infinitely many solutions — the Pythagorean triples (3, 4, 5), (5, 12, 13), (8, 15, 17) and so on. For n = 3 or higher, no solutions exist. Equivalently, it suffices to prove the theorem for n = 4 and every odd prime n = p ≥ 3; Fermat himself proved the n = 4 case using infinite descent.

Did Fermat actually have a proof?

Almost certainly not. Fermat wrote 'I have discovered a truly marvelous proof of this proposition, which this margin is too narrow to contain' next to the conjecture around 1637 in the margin of Diophantus's Arithmetica. He never wrote it down elsewhere and made no further reference to it. Mathematicians widely believe Fermat thought he had a proof but later discovered the flaw — he did publish a correct proof of the n = 4 case but never the general statement, suggesting he abandoned the general claim.

How did Wiles prove it?

Wiles proved a key case of the modularity theorem (then called the Taniyama-Shimura-Weil conjecture): every semistable elliptic curve over Q is modular. Gerhard Frey had observed in 1984 that a solution a^p + b^p = c^p would yield an elliptic curve y² = x(x − a^p)(x + b^p) with strange properties. Ribet's theorem (1986) proved this curve could not be modular. Modularity for semistable curves contradicts the Frey curve's existence — so no solution exists. Wiles worked alone in secret 1986–1993, announced June 1993, plugged the gap with Taylor October 1994, published 1995.

What happened between Wiles's 1993 announcement and the 1994 proof?

Wiles announced the proof at the Newton Institute, Cambridge on June 23, 1993, after three lectures titled 'Modular forms, elliptic curves, and Galois representations.' Reviewers Nick Katz and Luc Illusie soon found a serious gap in the Euler system argument. Wiles worked for a year trying to fix it, ready to publish what he could, when in September 1994 he and his former student Richard Taylor switched approaches and used a Kolyvagin–Flach modification combined with Hecke-algebra methods. The corrected proof was finished in October 1994 and published in two Annals of Mathematics papers in 1995 — 109 pages total (Wiles) and 24 pages (Taylor–Wiles).

Why is n = 2 a special case with infinitely many solutions?

Pythagorean triples (a, b, c) with a² + b² = c² are parametrised by (m² − n², 2mn, m² + n²) for integers m > n > 0. This gives infinitely many primitive triples. The geometric reason — the equation x² + y² = 1 is a unit circle, a rational curve (parametrised by rational functions of t). For exponent ≥ 3 the corresponding curve has positive genus and, by Faltings's theorem (1983), only finitely many rational solutions — Fermat says zero non-trivial.

What are some known cases proved before Wiles?

n = 4: Fermat himself via infinite descent. n = 3: Euler 1770 (with a small gap repaired by Legendre and Gauss). n = 5: Dirichlet and Legendre 1825. n = 7: Lamé 1839. The 'regular prime' cases: Kummer 1850 via ideal theory — proving FLT for all primes p whose class number of Q(ζ_p) is coprime to p. This handled all primes below 100 except 37, 59, 67. By 1993 computer verification covered all primes up to about 4 × 10^6 (Buhler–Crandall–Sompolski 1993). None of these methods scaled to all n.

What was the prize for proving FLT?

Paul Wolfskehl, a German doctor and amateur mathematician, bequeathed 100,000 Deutschmark in 1908 (about $4M in 2025 dollars) to whoever proved FLT before September 2007. Wiles received the Wolfskehl Prize in 1997 — its value had dropped to about $50,000 due to inflation and the bank's restructuring. He also received the Cole Prize (1996), the Wolf Prize (1996), the King Faisal Prize (1998), and was knighted in 2000. The Abel Prize followed in 2016, citing FLT and modularity.