Fermat's Last Theorem: The 358-Year Math Mystery Finally Solved

Photo: Jean-Rene Chazottes / Pexels
Fermat's Last Theorem fits in one line: the equation aⁿ + bⁿ = cⁿ has no solutions in positive whole numbers when n is greater than 2. Pierre de Fermat scribbled that claim in a book margin around 1637 and said he had a proof. Nobody found one for 358 years, until Andrew Wiles published his in 1995. Here is how the problem runs from a schoolroom triangle to the elliptic curves at the heart of the proof, and why a statement a child can read took a lifetime of mathematics to settle.
Key takeaways
- Fermat's Last Theorem says aⁿ + bⁿ = cⁿ has no positive whole-number solutions for any exponent n greater than 2
- Fermat proved only the n = 4 case; Euler, Dirichlet, Legendre, Lamé, and Kummer pushed the frontier case by case, and computers checked exponents into the millions, none of which amounted to a proof
- The break came from an unexpected direction: in 1986 Ken Ribet showed that a conjecture about elliptic curves would imply the theorem
- Andrew Wiles, with help from Richard Taylor, proved enough of that conjecture in 1994 and 1995, using mathematics that did not exist in Fermat's century
The surprising part: by 1993, computers had confirmed the theorem for every exponent up to four million. That counted for nothing as a proof, because a million confirmed cases leave infinitely many untested ones (MacTutor).
What the theorem says, and why n = 2 is different
Start with the equation everyone meets in school. A Pythagorean triple is a set of whole numbers a, b, and c with a² + b² = c². The smallest is 3² + 4² = 5², because 9 + 16 = 25. Others follow: 5² + 12² = 13² (25 + 144 = 169), 8² + 15² = 17² (64 + 225 = 289), and 7² + 24² = 25² (49 + 576 = 625). Such triples are tied to the name of Pythagoras, though the Babylonians had studied them long before (Wikipedia).
There are infinitely many of them, and a recipe produces every one you could want. Pick whole numbers m and n with m larger than n, and the three numbers m² − n², 2mn, and m² + n² always satisfy the equation, as a few lines of algebra confirm. Set m = 2 and n = 1 and you get 3, 4, 5. Set m = 3 and n = 2 and you get 5, 12, 13.
Fermat asked what happens when the exponent goes up. Are there whole numbers with a³ + b³ = c³? Or a⁴ + b⁴ = c⁴? His claim was that the answer is no for every exponent above 2. The equation is a door standing wide open at n = 2 and sealed at every exponent after it.
Two clarifications keep the statement honest. The numbers must be positive, because zero gives trivial solutions (0ⁿ + bⁿ = bⁿ for any b). And the exponent must be a whole number; the claim says nothing about exponents like 2.5.
| Exponent n | Test case | What you find |
|---|---|---|
| 1 | 1 + 2 = 3 | Solutions everywhere |
| 2 | 3² + 4² = 5² | Infinitely many |
| 3 | 6³ + 8³ = 728, while 9³ = 729 | Misses by one; no exact solution exists |
| 3 | 9³ + 10³ = 1,729, while 12³ = 1,728 | Misses by one the other way; no exact solution exists |
Those near misses are the trap. Cubes seem to want to add up to a cube and fall short by a single unit, which tempts you to believe an exact hit is hiding somewhere among larger numbers. Checking a few cases cannot rule that out, because the supply of numbers never ends. A proof has to be an argument that covers every combination at once, the way a single engineering calculation can certify a bridge for every possible load, where road-testing it with trucks one at a time never could.
The margin note and the one proof Fermat left
Fermat was reading a Latin edition of Diophantus's Arithmetica, published by Claude Bachet in 1621, when he wrote the note. He claimed to have found "a truly marvelous proof" that the margin was too narrow to contain (Wikipedia). The note is usually dated to about 1637, though some accounts place it earlier in the 1630s. Fermat never published it. He died in 1665, and his son Samuel found the note while collecting his father's papers and printed it in an annotated edition in 1670.
What survives is a proof for exactly one exponent. Fermat showed that the area of a right triangle with rational sides can never be a perfect square, and that result implies there are no whole-number solutions to x⁴ + y⁴ = z⁴ (MacTutor). He did it with a technique he called infinite descent.
Infinite descent works like a staircase that must end. Suppose a solution existed in positive whole numbers. Fermat showed you could always manufacture a smaller solution from it, and then a smaller one from that, and so on. But positive whole numbers cannot shrink forever; there is a floor at 1. A solution that forces an endless descent to nothing cannot have existed in the first place.
Why only prime exponents matter
Once n = 4 was settled, the rest of the problem shrank. Every whole number above 2 is divisible by 4 or by an odd prime. If a⁶ + b⁶ = c⁶ had a solution, then (a²)³ + (b²)³ = (c²)³ would be a solution for n = 3, so ruling out the cube case rules out the sixth-power case too. Proving the theorem for n = 4 and for every odd prime exponent therefore covers all the rest (Wikipedia). That left an endless list of primes (3, 5, 7, 11, and onward; for how mathematicians hunt through that list, see the search for the largest known prime) and a very long road.
Three centuries of partial victories
The 1600s and 1700s produced no general argument, only individual cases. The table lists the main ones.
| Year | Who | What they settled |
|---|---|---|
| 1630s | Fermat | n = 4, by infinite descent |
| 1770 | Euler | n = 3 (the published argument had a gap that was later filled) |
| 1825 | Dirichlet and Legendre | n = 5 |
| 1832 | Dirichlet | n = 14 |
| 1839 | Lamé | n = 7 |
| 1847 | Kummer | Every "regular" prime exponent |
| 1983 | Faltings | For each n above 2, at most finitely many coprime solutions |
| 1993 | Computer searches | Every exponent up to 4,000,000 |
Sources: MacTutor and Wikipedia.
Leonhard Euler wrote to Christian Goldbach in 1753 claiming a proof for cubes, and his Algebra of 1770 printed one. It contains a step that is correct but unjustified, which is why textbooks describe it as flawed. Euler is still credited with the result, since he had proved the missing lemma in other work (Wikipedia). Sophie Germain made early progress on the general problem. She handled what is called the first case, where the exponent p does not divide the product abc, for a large family of primes, and Legendre extended her methods (MacTutor).
The 1847 collapse, and the idea it left behind
The most dramatic failure came in Paris. On March 1, 1847, Gabriel Lamé announced a proof that factored aⁿ + bⁿ into pieces built from complex numbers, and the argument depended on those pieces breaking apart in only one way. Joseph Liouville doubted that uniqueness held. On May 24, 1847, he read to the Académie a letter from Ernst Kummer showing that it fails (MacTutor).
Unique factorization is easy to take for granted. Among ordinary whole numbers, 12 breaks into primes in exactly one way: 2 × 2 × 3. Number systems exist where that guarantee fails. In the system built from whole numbers and √−5, the number 6 equals 2 × 3 and also equals (1 + √−5)(1 − √−5), and neither factorization can be broken down further. Lamé's proof quietly assumed the comfortable behavior of whole numbers in a setting that does not have it.
Kummer's repair was to invent "ideal complex numbers," introduced in 1846, which restore unique factorization at the cost of an abstract new idea. With them he proved the theorem for all regular primes, a class defined through the Bernoulli numbers. The irregular primes below 100 are 37, 59, and 67, and primes like these needed separate treatment (MacTutor). The attempt on Fermat failed, but Kummer's ideals became the seed of what algebraists call ideal theory, an idea that later mathematicians, Emmy Noether among them, built into the foundations of abstract algebra. The problem kept paying out in side discoveries long after it refused to pay out its own answer.
A prize, and a flood of wrong proofs
In 1908, the Göttingen Academy of Sciences announced a prize of 100,000 marks for a proof, funded by the will of Paul Wolfskehl (MacTutor). Thousands of attempts arrived over the decades. By the time Wiles collected the prize in 1997, it had dwindled to about 75,000 Deutschmarks (MacTutor). Wikipedia's entry on Wolfskehl dates the award to June 27, 1997 (Wikipedia).
Why a computer check can never settle it
By the twentieth century, machines took over the case-by-case approach. Vandiver verified the theorem for primes up to 2,521 in 1954 on the SWAC computer. Wagstaff pushed the limit to 125,000 by 1978, and by 1993 every prime below four million had been checked (Wikipedia).
Mathematicians knew the theorem was very likely true. They also knew how badly "very likely" can go wrong in number theory. In 1769 Euler conjectured that you need at least four fourth powers to add up to another fourth power; three should never be enough. The conjecture stood for 219 years. Then in 1988 Noam Elkies found 2,682,440⁴ + 15,365,639⁴ + 18,796,760⁴ = 20,615,673⁴ (The Prime Pages). A pattern that holds through every number you can feasibly test can still be false.
That is the difference between a check and a proof. A check is a very long list of true statements. A proof is a short argument whose logic is indifferent to how large the numbers get.
The detour: elliptic curves and modular forms
The route to a proof ran away from Fermat's equation altogether, into two fields that looked unrelated.
An elliptic curve is the set of points satisfying an equation like y² = x³ + ax + b, with a mild condition that rules out degenerate cases. Despite the name, it is not an ellipse. What matters is that its solutions form a rich structure, and you can learn a lot by counting solutions modulo a prime p, meaning you only allow x and y to take the values 0 through p − 1 and work with remainders.
Take the curve y² + y = x³ − x. Modulo 2 it has four solutions, and modulo 3 it has six. Subtract each count from p and you get a pair of numbers, −2 and −3. Those counts, computed for every prime, form the curve's fingerprint (Wikipedia).
A modular form is something completely different: a complex-valued function with an enormous amount of symmetry, so much that its behavior is pinned down by a list of numbers. One such function has the list q − 2q² − 3q³ + 2q⁴ − …, and its coefficients at 2 and 3 are −2 and −3, which match the fingerprint of the curve above. That is not a coincidence. The modularity theorem says that every elliptic curve over the rational numbers is linked to a modular form in exactly this way (Wikipedia).
Think of it as a Rosetta Stone. The curve says its message in the language of algebra, the modular form says the same message in the language of symmetry, and the counting numbers are the matching words. In 1955, at a symposium in Tokyo and Nikkō, Yutaka Taniyama posed a problem that hinted at such a dictionary. Goro Shimura refined it through 1957, and André Weil sharpened it in 1967, which is why the statement was long called the Taniyama-Shimura-Weil conjecture (Wikipedia).
For decades, nobody connected this to Fermat. It looked like a separate and very hard question about curves.
How a hypothetical solution gives a curve that cannot exist
The link was found in pieces. In 1975, Yves Hellegouarch first associated solutions of Fermat's equation with an elliptic curve. Gerhard Frey drew attention to the unusual properties of such curves in 1982 and, in 1986, suggested that the Taniyama-Shimura conjecture would imply Fermat's Last Theorem (Wikipedia).
The idea runs as a proof by contradiction, in five steps:
- Suppose a counterexample existed: positive whole numbers with aᵖ + bᵖ = cᵖ for some odd prime p.
- Build from it the Frey curve y² = x(x − aᵖ)(x + bᵖ).
- Jean-Pierre Serre proposed in 1985 that such a curve could not be modular, and the missing piece of the argument, the epsilon conjecture, was proved by Ken Ribet in summer 1986 and published in 1990.
- Wiles's theorem says that every semistable elliptic curve over the rationals is modular.
- The Frey curve is both semistable and, by Ribet, not modular, which is impossible. So the counterexample never existed.
The logic resembles a locked-room puzzle. If the suspect had been inside, he would have had to be in two places at once, so he was never inside. Ribet showed that a counterexample would create a curve that is not modular. Wiles had to show that curves of that type are always modular, so the supposed counterexample would be both. Once Ribet's step was in place, the whole of Fermat's problem rested on one question about elliptic curves, and Fermat's equation could be forgotten (Wikipedia).
Seven years in an attic, one announcement, one gap
Andrew Wiles was born in Cambridge, England, on April 11, 1953. At age ten he read Eric Temple Bell's The Last Problem in a public library and decided to prove Fermat's Last Theorem himself (MacTutor). He became a number theorist, took his doctorate under John Coates in 1980, and joined the Princeton faculty in 1982.
Then Ribet's theorem arrived. Fermat's problem was no longer a pariah; it was a question about elliptic curves, which was exactly Wiles's field. He worked on it in complete secrecy for seven years, thinking about it "all the time" (Simon Singh). The reason is easy to guess: a public attack on Fermat's Last Theorem invites ridicule if it fails.
| Date | Event |
|---|---|
| Summer 1986 | Ribet proves the epsilon conjecture; Wiles begins private work |
| June 21 to 23, 1993 | Three lectures at the Isaac Newton Institute, Cambridge, announce a proof |
| August or September 1993 (sources differ) | Referees' questions expose a gap in the argument |
| December 4, 1993 | Wiles withdraws his claim, citing a gap in a Selmer group calculation |
| Early 1994 | Richard Taylor, Wiles's former student, joins the repair |
| September 19, 1994 | Wiles sees how to combine Iwasawa theory with lessons from the Kolyvagin-Flach approach |
| October 6, 1994 | The new proof is sent to three colleagues, including Faltings |
| May 1995 | Two papers appear in Annals of Mathematics |
Sources: MacTutor and Wikipedia.
The Cambridge lectures ended on June 23, 1993, when Wiles announced Fermat's Last Theorem as a corollary of his main results and then said simply that he would stop there (MacTutor). That was not the end of the story. A referee, Nick Katz, asked questions that led Wiles to discover an error in the Euler-system part of the argument (Wikipedia). For about a year he tried to repair it, alone at first and then with Taylor.
The fix came on September 19, 1994. Wiles described it as "the most important moment of [his] working life," a moment when he saw that an approach he had tried earlier and set aside, combined with another, resolved the problem (Wikipedia; MacTutor). He and Taylor published two papers in the May 1995 issue of Annals of Mathematics: Wiles's "Modular elliptic curves and Fermat's Last Theorem" on pages 443 to 551, and the Taylor-Wiles paper on pages 553 to 572. Together they run about 130 printed pages.
What the proof is made of
The finished argument does not so much attack Fermat's equation as build a bridge between two mathematical worlds, one plank at a time. The names of the planks give some feel for it (Wikipedia):
- Galois representations. A Galois representation records how the symmetries of an equation's solutions shuffle them, the way choreography records how dancers swap places. The idea goes back to Évariste Galois, who studied exactly this kind of shuffling in the 1830s.
- Modularity lifting. Suppose you know that one version of a Galois representation comes from a modular form. Modularity lifting shows that the modularity survives when you "lift" the representation to finer and finer levels of detail.
- Hecke algebras and the R = T idea. The lifting argument matches two rings of numbers, one built from deformations of the representation and one from modular forms, and shows they are the same.
- The Langlands-Tunnell theorem and the 3-5 trick. Wiles needed a starting point he could prove was modular. The Langlands-Tunnell theorem supplied one for a specific prime, and a switch between the primes 3 and 5 handled cases where the first choice failed.
The architecture is like proving a tall building sound by confirming the ground floor and then showing that each new floor inherits the strength of the one beneath. Wiles's version only covered what mathematicians call the semistable case, a restriction on how the curve behaves at certain primes. Ribet's step meant that was enough. In 2001 Christophe Breuil, Brian Conrad, Fred Diamond, and Richard Taylor extended the result to every elliptic curve over the rationals, at which point the conjecture became the modularity theorem (Wikipedia).
Did Fermat actually have a proof?
Almost certainly not the proof anyone has found since, and quite possibly not a correct proof at all. Fermat's note describes no method, and no proof of the general case survives in his papers. The argument that eventually worked needed ideas such as elliptic curves, modular forms, and Galois representations, none of which existed in the 1600s.
The most plausible explanations are ordinary ones. Fermat may have had a proof of the n = 4 case, which we know he did have, and extended it too optimistically. Or he may have fallen into the same trap as Lamé two centuries later, assuming that numbers in a larger system behave like whole numbers. Lamé's 1847 slip shows how natural that assumption feels. A great mathematician working in private, with no colleagues to check him, could have reached the same dead end. Nobody can say for certain, because the note says nothing about the method.
What the proof left behind
The theorem itself has no everyday use. The connections built to prove it are what matter. The correspondence between elliptic curves and modular forms is one case of the Langlands program, a web of conjectured links between number theory, geometry, and analysis. Wiles shared the 1996 Wolf Prize with Robert Langlands (MacTutor). He was made a Knight Commander of the Order of the British Empire in 2000, and in 2016 he received the Abel Prize "for his stunning proof of Fermat's Last Theorem by way of the modularity conjecture for semistable elliptic curves," an achievement the citation says opened "a new era in number theory" (Abel Prize).
The story is also still moving. A project led by Kevin Buzzard at Imperial College London is formalizing a proof of Fermat's Last Theorem in the Lean theorem prover, so that a computer can verify every logical step. The route was planned mainly by Richard Taylor together with Buzzard and is a modern variant of the Wiles and Taylor-Wiles proof; the project's repository says its funding, an EPSRC grant, runs until September 2029 (GitHub). It is a reminder of how much machinery stands behind a statement that fits on a napkin.
What a mathematical proof is, and what it isn't
Wiles's result illustrates why mathematics sits apart from the experimental sciences. A scientific theory is supported by evidence and stays open to revision. A mathematical theorem, once proven, is settled for every case there is. Nothing discovered next year can overturn Fermat's Last Theorem, any more than a new experiment could make 2 + 2 equal 5.
That certainty has limits of its own. Kurt Gödel showed in 1931 that any consistent, effectively specified formal system strong enough to describe arithmetic contains true statements it cannot prove. Fermat's claim turned out not to be one of them, but nothing guaranteed that in advance, and for 358 years nobody knew whether the theorem was provable at all. For a longer view of how mathematicians got from Euclid's geometry to modern proofs like this one, see the history of mathematics from Euclid to Turing.
Common mix-ups about Fermat's Last Theorem
It is not Fermat's Little Theorem. Fermat's Little Theorem is a different and much easier result: for a prime p and any whole number a, aᵖ − a is divisible by p. With p = 5 and a = 2, that is 32 − 2 = 30, which is divisible by 5.
"Last" does not mean the final thing Fermat wrote. The name reflects that it was the last of his claims left unresolved, and for centuries it was a conjecture in all but name.
Wiles did not prove every elliptic curve modular in 1995. He proved the semistable case, which was enough. The full statement waited until 2001.
The theorem is not about all numbers. The numbers must be positive whole numbers, and the exponent must be a whole number above 2.
"Simple to state" does not mean "simple to prove." Many problems in number theory are easy to read and brutally hard to settle, and the size of Fermat's margin is no evidence that a short proof exists.
The takeaway
Fermat's Last Theorem never needed a better attack on its own equation. It needed a different question. For three centuries mathematicians tried to settle it exponent by exponent, and what they found along the way, from Kummer's ideal numbers to Germain's partial results, was richer than the answer. The break came when Frey, Serre, and Ribet turned the equation into a statement about elliptic curves, and Wiles and Taylor then proved enough of it to close the case. The lesson is not that the problem was secretly easy. It is that the right view of a hard question can be a view from somewhere else entirely.
FAQ
Q: Why was Fermat's Last Theorem so hard to prove when it is so easy to state? A: The statement concerns infinitely many equations at once, one for each exponent, and each involves infinitely many candidate numbers. Case-by-case work, like Euler's for cubes and Dirichlet and Legendre's for fifth powers, never reached the general result. The proof that worked required elliptic curves, modular forms, and Galois representations, concepts that did not exist in Fermat's century.
Q: Did Fermat actually have a proof? A: Probably not one that worked. No argument for the general case survives, and the proof that was eventually found relies on twentieth-century mathematics. He did leave a valid proof for n = 4, using infinite descent, and he may have overestimated how far that method would stretch.
Q: What exactly did Andrew Wiles prove? A: Wiles proved that every semistable elliptic curve over the rational numbers is modular. Ken Ribet had shown in 1986 that this case is enough to imply Fermat's Last Theorem. Taylor helped close a gap in the 1994 repair, and Breuil, Conrad, Diamond, and Taylor extended the modularity result to all elliptic curves in 2001.
Q: Can a computer prove Fermat's Last Theorem? A: Computers verified the theorem for exponents up to four million by 1993, but that cannot prove it for the infinitely many exponents beyond. A computer can check a proof, though. Kevin Buzzard's Lean project at Imperial College London aims to formalize a proof so that each step is machine-verified, with funding running to September 2029.
Q: Is there a simpler proof of Fermat's Last Theorem? A: None is known. Some mathematicians hope for an elementary proof that avoids elliptic curves and modular forms, but nobody has produced one. Given how many brilliant people failed to find any proof for 358 years, an elementary argument, if it exists, is likely to be very deep.
Q: How much did Wiles win for solving it? A: He collected the Wolfskehl Prize in 1997, which by then was worth about 75,000 Deutschmarks after decades of inflation. His other honors include the 1996 Wolf Prize, shared with Robert Langlands, a knighthood in 2000, and the Abel Prize in 2016.
Q: Why do people say the proof took seven years? A: Wiles began working on it privately after Ribet's 1986 result and spent about seven years in secrecy before the June 1993 Cambridge lectures. A gap found afterward took roughly another year to repair, so the whole effort stretched to the 1995 publication.
Sources
- MacTutor History of Mathematics, Fermat's last theorem
- MacTutor, Andrew Wiles biography and Wolfskehl prize note, June 27
- Wiles A. Modular elliptic curves and Fermat's Last Theorem. Annals of Mathematics 1995;141(3):443-551. Taylor R, Wiles A. Ring-theoretic properties of certain Hecke algebras. Annals of Mathematics 1995;141(3):553-572. Summary in Wikipedia
- Wikipedia, Fermat's Last Theorem, Frey curve, Modularity theorem, and Paul Wolfskehl
- The Abel Prize, 2016 laureate Andrew Wiles
- The Prime Pages, Elkies counterexample to Euler's conjecture
- Simon Singh, Who is Andrew Wiles?
- Imperial College London, Fermat's Last Theorem formalisation project
Read next:
Follow new articles
Add SciHub101 to your feed reader to see new science and technology stories.
About the Author
SciHub101 is an independent science and technology publication founded and edited by Buğra Sözeri, a software engineer and app developer based in Türkiye. AI tools assist with drafting and research. Source documentation in the existing archive is uneven, and articles are being reviewed and corrected. The Editorial Team byline identifies editorial responsibility; it does not certify specialist or independent human review. Where we compare products, anything built by our own team is labelled as such — see the editorial guidelines and About page for how corrections and disclosures work.
Related Articles

How Atoms and Molecules Work: The Basics of Chemistry
Everything you touch, breathe, and eat is built from atoms. Here is how a handful of particles bond into the molecules and crystals that make up ordinary matter.

Amedeo Avogadro: Equal Volumes, Equal Particles
Avogadro proposed that equal volumes of gases contain equal numbers of particles. His insight bridged atomic and molecular theory, enabling modern chemistry's quantification.

Infinity in Mathematics: How Some Infinities Are Bigger Than Others
Not all infinities are equal. Georg Cantor proved that some infinite sets are larger than others — a discovery so strange it drove mathematicians mad.

How Prime Numbers Work: The Math Behind Internet Security
Prime numbers seem like a curious curiosity from school math. They're actually the foundation of every secure transaction on the internet — and one of the deepest mysteries in mathematics.

What Is the Largest Known Prime Number — And Why Do Mathematicians Keep Searching?
The largest known prime number has 41,024,320 digits. Finding it took a rented cloud of data-center GPUs and a decades-old search project. But what is the point of a number nobody will ever write out?

The Fibonacci Sequence and the Golden Ratio in Nature
Sunflowers, nautilus shells, pinecones, and galaxies — the Fibonacci sequence seems to appear everywhere in nature. Some of it is real mathematics; some is pattern-matching wishful thinking. Here's the honest story.