Sometime around 1637, the French magistrate and amateur mathematician Pierre de Fermat was reading a Latin edition of Diophantus’s Arithmetica. In the margin, next to a problem about Pythagorean triples, he wrote a note in his characteristically clipped Latin:

Cubum autem in duos cubos, aut quadratoquadratum in duos quadratoquadratos, et generaliter nullam in infinitum ultra quadratum potestatem in duos eiusdem nominis fas est dividere cuius rei demonstrationem mirabilem sane detexi. Hanc marginis exiguitas non caperet.

In plain English: it is impossible to write a cube as the sum of two cubes, a fourth power as the sum of two fourth powers, or any higher power as the sum of two like powers — and I have discovered a truly marvellous proof of this, which this margin is too narrow to contain.

Fermat never wrote the proof down anywhere else. He died in 1665. For the next 358 years, essentially every serious mathematician in Europe tried to reconstruct what Fermat had claimed, and most concluded that he had been mistaken. The theorem was finally proved by Andrew Wiles, a British mathematician working at Princeton, in a 1995 paper that ran to over 100 pages and relied on mathematics that would have been entirely alien to the seventeenth century.

This is the story of that gap — how the shortest theorem in mathematics produced one of the longest proofs, and what it reveals about how mathematical progress actually happens.

The statement

Fermat’s Last Theorem is startlingly simple to state. For the equation

xn+yn=znx^n + y^n = z^n

there are no positive integer solutions x,y,zx, y, z when nn is an integer greater than 2.

When n=2n = 2, of course, there are infinitely many solutions — these are the Pythagorean triples: (3,4,5)(3, 4, 5), (5,12,13)(5, 12, 13), (8,15,17)(8, 15, 17), and so on. The question is why the pattern breaks as soon as the exponent reaches 3.

To a non-mathematician this can sound uninteresting. Who cares whether cubes can be written as sums of cubes? The answer is that the resistance of the problem — the fact that nobody could prove or disprove it — made it a magnet for new mathematics. Every attempt to crack Fermat produced theory that turned out to matter for entirely unrelated reasons.

Three centuries of partial progress

The chronology of attempts tells you a lot about how mathematical research accumulates.

Fermat himself proved the case n=4n = 4 using a technique he called “infinite descent” — assuming a solution exists and deriving a smaller solution, contradicting itself forever. The method is genuinely elegant and works for n=4n = 4. It does not scale.

Euler proved the case n=3n = 3 around 1770, though his argument had a subtle gap that was later patched. To do it, he worked in a number system larger than the integers — specifically, numbers of the form a+b3a + b\sqrt{-3} — and the move foreshadowed the central strategy of future attempts: if the integers aren’t rich enough, extend them.

Sophie Germain, working alone in early-nineteenth-century Paris under a male pseudonym because women were barred from academic mathematics, made the first systematic attack on the general case. Her theorems applied to an infinite family of primes (now called Germain primes in her honour). Her work forced the problem in a serious direction for the first time.

Kummer, in the 1840s, tried to generalize Euler’s trick and ran into a disaster that turned into a revolution. The number systems you need to factor expressions like xn+ynx^n + y^n do not always have unique prime factorization — an assumption so basic in the integers that nobody had thought to check it elsewhere. Kummer’s response was to invent “ideal numbers,” a conceptual repair that became the foundation of modern algebraic number theory. He proved Fermat’s theorem for all “regular” primes, covering the vast majority of cases but not all of them.

From Kummer’s work onwards, Fermat’s Last Theorem was understood to be an entrance to a deeper structure. The theorem itself started to feel secondary to the mathematics it generated.

The modern breakthrough

The story jumps to 1955. Two Japanese mathematicians, Yutaka Taniyama and Goro Shimura, proposed what sounded like a wild idea: every elliptic curve over the rational numbers is, in a precise technical sense, a modular form in disguise. This became known as the Taniyama–Shimura conjecture (later the modularity theorem).

At the time, nobody noticed the connection to Fermat. Elliptic curves and modular forms were separate subjects, both advanced, and Taniyama–Shimura was a statement about their secret equivalence. Fermat’s theorem was about Diophantine equations, a different subject entirely.

Then in 1985, the German mathematician Gerhard Frey noticed something astonishing. Suppose Fermat’s Last Theorem were false. Suppose there were a solution ap+bp=cpa^p + b^p = c^p for some prime p5p \geq 5. Then the elliptic curve

y2=x(xap)(x+bp)y^2 = x(x - a^p)(x + b^p)

— now called the Frey curve — would have extraordinarily strange properties. Frey argued informally that if this curve existed, it could not be modular. If Taniyama–Shimura was true, then no such curve could exist, which meant the Fermat equation had no solutions.

The logic was: Taniyama–Shimura → Fermat’s Last Theorem. A conjecture nobody had proved was implying another conjecture nobody had proved. But a bridge between them had been built.

Ken Ribet, an American mathematician, made Frey’s argument rigorous in 1986. The route to Fermat now lay entirely through Taniyama–Shimura. If anyone could prove that, Fermat would fall as a corollary.

Wiles’s proof

Andrew Wiles had been obsessed with Fermat’s Last Theorem since he was ten years old, when he read about it in a library book and never quite let go. When Ribet’s result landed, Wiles — by then a Princeton professor specialising in elliptic curves — realised he had spent his whole life training for the one problem he needed.

He withdrew from regular academic life for seven years. He told almost nobody what he was working on. He published a few short papers to keep up appearances but spent the bulk of his time in his attic, attacking Taniyama–Shimura for a restricted class of elliptic curves — just enough to get Fermat.

In June 1993, Wiles announced his result at a conference in Cambridge. The lecture hall was packed. He walked through his argument over three days and, at the end of the third day, wrote Fermat’s Last Theorem on the blackboard and quietly said: “I think I’ll stop here.”

Then, in the subsequent months, a referee found a gap.

The error was not fatal to the overall approach, but it was real. For a period in 1993–1994 Wiles could not see how to fix it. He described the year that followed as the hardest of his life. Eventually, with the help of his former student Richard Taylor, he found an alternative route that repaired the argument. The corrected proof was published in 1995.

For his proof he was eventually awarded the Abel Prize, the Wolf Prize, and nearly every other major honour in mathematics — with one exception. The Fields Medal is awarded only to mathematicians under 40. Wiles was 41 when he completed the proof. The committee made a special plaque for him, but they could not give him the medal.

What the proof actually uses

The reason the proof is so long is that it’s essentially the solution to a different, far more general problem — the modularity of semistable elliptic curves — and Fermat’s Last Theorem falls out as a corollary.

The machinery involves:

  • Elliptic curves over the rational numbers, and their reduction modulo primes.
  • Modular forms, certain holomorphic functions on the upper half-plane with strong symmetry properties.
  • Galois representations, which encode how the absolute Galois group of the rational numbers acts on torsion points of elliptic curves.
  • Deformation theory of Galois representations — a way of studying how representations can vary continuously.

Wiles’s core technical innovation was a “modularity lifting theorem”: a way to show that if a certain mod-pp Galois representation is modular, then a lift of it to characteristic zero is modular too. This is what lets you connect elliptic curves (geometry) to modular forms (analysis) through arithmetic.

None of this existed in Fermat’s time. Elliptic curves as we understand them were not studied until the nineteenth century. Modular forms came later. Galois representations are a twentieth-century invention. Fermat’s “marvellous proof” almost certainly never existed; if it did, it used tools we don’t have and probably had a flaw that Fermat didn’t notice.

What it means for mathematics

Fermat’s Last Theorem is not the most important result Wiles proved. The modularity theorem — which says every semistable elliptic curve over Q\mathbb{Q} is modular, now extended to all elliptic curves — is vastly more consequential. It’s a load-bearing piece of the Langlands program, a network of conjectures linking number theory, representation theory, and geometry that remains the dominant research agenda in arithmetic today.

Fermat’s theorem was the tip; the iceberg was modularity. The reason this matters is that mathematical progress rarely looks like the hero storyline popular accounts tell. The real work was happening continuously for 358 years — Sophie Germain, Kummer, Taniyama, Shimura, Frey, Ribet, and dozens of others. Wiles put the final brick into a building that had been under construction for generations.

The other lesson is about what hard problems do. Fermat’s Last Theorem, by refusing to be proved, generated more new mathematics than any theorem of its size in history. It forced the creation of algebraic number theory, pushed Galois theory into its modern form, and eventually tied together elliptic curves, modular forms, and Galois representations — fields that would otherwise have stayed apart.

Mathematicians often joke that the only thing better than proving a hard conjecture is having a hard unproved conjecture around. It keeps you honest, and it forces the subject to grow.

Fermat’s note in the margin, whether he had a proof or not, ended up being one of the most productive accidents in the history of mathematics.

Frequently asked

Did Fermat really have a proof?

Almost certainly not — at least not a correct one. The mathematical machinery Wiles eventually needed (modular forms, elliptic curves, Galois representations) did not exist in the seventeenth century. Fermat probably had an argument that worked for special cases and mistakenly believed it generalized.

Is the proof accessible to non-specialists?

No. Wiles's proof runs over 100 pages and relies on deep machinery from algebraic geometry and number theory that takes years of graduate study to absorb. Even sketching the argument accurately requires concepts like modular forms, L-functions, and Galois representations.