[[caption-width-right:300:[[TheNineties The USSR, Apartheid, and now this]]. Is nothing sacred?]]

->''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.''

->("It is impossible for a cube to be the sum of two cubes, a fourth power to be the sum of two fourth powers, or in general for any number that is a power greater than the second to be the sum of two like powers. I have discovered a truly marvelous demonstration of this proposition that this margin is too narrow to contain.")[[note]]In LaymansTerms, take this equation: x^n plus y^n equals z^n. The Last Theorem says that if n is a number above 2, then x, y, and z can't all be whole numbers (2, 3, 4, etc.).[[/note]]

-->-- '''Pierre de Fermat'''

Fermat, a prominent 17th-century amateur mathematician, wrote the above note in his copy of a number theory textbook. By the time he died, the textbook was full of such teasing notes; his son published a new annotated edition of the book containing all of these notes in their proper places.

For nearly all the notes, it didn't take long for other mathematicians to figure out what Fermat was talking about. The quoted one was the exception. As such, it became known as Fermat's last theorem--"last" not in the sense that it was the last mathematics he ever did (he almost certainly wrote the note fairly early in his life) but in the sense that it was the last claim he made to remain unproven. It took until nearly 350 years after Fermat's death until mathematicians Andrew Wiles and Richard Taylor released a proof in 1994.

In fact, it's almost certain that Fermat himself didn't really have a proof. Wiles' proof certainly would have been inaccessible to Fermat; it relies on mathematical concepts which weren't developed until after the Second World War. Romantically, one might imagine that Fermat had come up with some simple proof that has since eluded everyone else. In reality it's far more likely that he was mistaken, especially since later in life he went to the effort of working out a proof for a certain special case (that no fourth power can be written as the sum of two fourth powers)[[note]]Though he could still have had a general proof for all odd numbers or odd primes, since proving the case for all odd numbers/primes and 4 would prove Fermat's last theorem for all cases[[/note]]. In fact, 19th-century mathematician Gabriel Lamé had a flawed proof attempt that could have been much like Fermat's -- the idea is just about practicable for a brilliant 17th century mathematician, whereas the flaw in it is a rather subtle technical matter that escaped just about everyone even in the 19th century.

There's often this idea in fiction that Wiles' proof is somehow incomplete or not good enough (mostly for being utterly ''inelegant''--note, however, that [[http://en.wikipedia.org/wiki/Catalan_conjecture mathematics]] [[http://en.wikipedia.org/wiki/Four_color_theorem is]] [[http://en.wikipedia.org/wiki/Jordan_curve_theorem full]] [[http://en.wikipedia.org/wiki/Graph_minor_theorem of]] [[http://en.wikipedia.org/wiki/Classification_of_finite_simple_groups theorems]] whose best-known proof is massively more difficult and complex than the statement of the theorem itself; Fermat's last theorem is by no means unique in this regard). No ''currently'' unsolved problem in mathematics has a story behind it that's nearly as good as Fermat's mysterious margin note, so it can be useful to pretend that Fermat's last theorem remains unsolved.

Not to be confused with Fermat's [[http://en.wikipedia.org/wiki/Fermat%27s_little_theorem Little Theorem]], which can be proved convincingly on the back of a postcard.

----

!! Instances of Fermat's last theorem in fiction:

* In Arthur Porges' short story "The Devil and Simon Flagg", a mathematician [[ChessWithDeath bets his soul]] that the Devil cannot prove Fermat's last theorem in twenty-four hours. [[spoiler:He wins.]]

** This causes some FridgeLogic along the way though, as this Devil is master of space and time among other things. Yet he didn't even try go back in time and ask Fermat himself.

*** Not at all, if we assume that Fermat himself was in error when noting he had a proof. Which is probably the case.

** A problem that might be substituted for Fermat's Last Theorem if reusing this plot would be to ask for [[http://en.wikipedia.org/wiki/Ramsey_number#Ramsey_numbers Ramsey numbers]]. Extra bonus for them being associated with an AlienInvasion anecdote.

** Even better would be one of the [[http://en.wikipedia.org/wiki/Category:Millennium_Prize_Problems Millennium Prize problems]], 7 math problems of which 6 remain unsolved.

*** [[http://en.wikipedia.org/wiki/P_versus_NP_problem P versus NP problem]]

*** [[http://en.wikipedia.org/wiki/Hodge_conjecture Hodge Conjecture]]

*** [[http://en.wikipedia.org/wiki/Poincar%C3%A9_conjecture Poincaré Conjecture]] (solved in 2002-'03, prize offered but declined by winner in 2010)

*** [[http://en.wikipedia.org/wiki/Riemann_hypothesis Riemann Hypothesis]] (this one comes closest to equalling the TropeNamer among still-unsolved math problems)

*** [[http://en.wikipedia.org/wiki/Yang%E2%80%93Mills_existence_and_mass_gap Yang-Mills existence & mass gap]]

*** [[http://en.wikipedia.org/wiki/Navier%E2%80%93Stokes_existence_and_smoothness Navier-Stokes existence and smoothness]]

*** [[http://en.wikipedia.org/wiki/Birch_and_Swinnerton-Dyer_conjecture Birch and Swinnerton-Dyer conjecture]]

* ''Franchise/StarTrek'':

** In ''Series/StarTrekTheNextGeneration'', Picard spends some time trying to prove Fermat's last theorem. He says he finds it humbling that an 800-year-old problem, first posed by a French mathematician without a computer, still eludes solution. (The episode in question was broadcast [[ScienceMarchesOn five years before Wiles' proof was released]].)

** In ''Series/StarTrekDeepSpaceNine'', Jadzia says that one of Dax's earlier hosts had the most original approach to Fermat's last theorem "since Wiles 300 years ago". This may be an attempted HandWave for the TNG example, by showing that people are still working on the problem in the ''Franchise/StarTrek'' universe even though it's been solved.

* In the ''Series/DoctorWho'' episode [[Recap/DoctorWhoS31E1TheEleventhHour "The Eleventh Hour"]], the Doctor uses Fermat's original proof of Fermat's last theorem[[note]](along with an explanation of why electrons have mass and a description of an FTL drive)[[/note]] to get a team of scientists to take him seriously after hacking into their videoconference. He also admits that the unfinished stuff was his fault as he "slept in".

* In the Literature/DoctorWhoMissingAdventures novel ''Millennial Rites'', it's mentioned in passing that the CorruptCorporateExecutive villain has an algebraic proof of the Theorem that he's keeping secret.

* Creator/ArthurCClarke's ''The Last Theorem'' is about a Sri Lankan mathematician who discovers a new proof of the Theorem that is not only considerably more concise than Wiles' version but doesn't rely on any mathematics that post-date Fermat, and thus might be Fermat's own proof.

* The Irish band BATS have a song about Andrew Wiles and the theorem.

* ''IrregularWebcomic'' posits that Fermat was a [[http://www.irregularwebcomic.net/1807.html time traveler]].

* "Prove Fermat's last theorem" occurs as a problem in an OnlySmartPeopleMayPass setup in ''GashBell''. It's posed to the dumbest member of the party, and the rest force the guardian to give a simpler question by making him admit that ''he'' doesn't know the answer.

* Shows up in ''Theatre/{{Arcadia}}''; as a joke Septimus assigns the TeenGenius Thomasina to solve it. She eventually comes to the conclusion that Fermat was {{Troll}}ing. Interestingly, ''Arcadia'' was published mere months before Wiles' proof.

* In TheMillenniumTrilogy, Lisbeth spends most of the second book puzzling over the Theorem. At the end of the book, she [[EurekaMoment understands what he meant]], but after the ending of the book, forgets it.

* Appears briefly on a blackboard in the 2000 remake of ''Film/{{Bedazzled 2000}}''. Satan (Elizabeth Hurley as a HotTeacher) erases it from the list of homework assignments while commenting, "You'll never use this stuff."

* In ''GetBackers'', Lucky, the genius dog, is given a problem like this to solve. The dog answers that it's unsolveable (x = "nothing"), which is what ''really'' clues [[InsufferableGenius Ban]] in to the fact that the whole "genius dog" thing isn't a parlor trick... the dog's actually been [[spoiler:infected with the same virus that caused apes to mutate into humans, the so-called "Missing Link Virus."]] It... doesn't make ''sense'' in context, but there is an explanation.

* The Musical ''Fermat's Last Tango'' is a NoCelebritiesWereHarmed version of a modern mathematician using computers to find the proof, while taunted by Fermat's ghost, returned from the afterlife (a specific one for mathematicians, called the [[IncrediblyLamePun After Math]]). (Was originally to be called ''Proof'', but premiered at the same time as ''{{Theatre/Proof}}''.)

* Tom Lehrer's "That's Mathematics" mentions Wiles' proof of "what Fermat jotted down in that margin, which could've used some enlargin'", though he makes it sound a ''lot'' simpler than it is.

* In the Dutch comic ''Storm: De Kronieken van Pandarve'' [[note]]Storm: The Chronicles of Pandarve[[/note]], the [[GeniusLoci planetary intelligence Pandarve]] tries to solve Fermat's theorem to pass the time. When Storm needs her full attention to deal with an incoming meteor, he reveals that the theorem was solved, and that he knew that all the time but never told her. Pandarve gets quite enraged at this, partially because a mere human proved smarter than her, but mostly because she is now ''bored''. She calms down when Storm tells her about another unsolved problem, [[http://en.wikipedia.org/wiki/Goldbach%27s_conjecture Goldbach's conjecture]].

----