It's a math problem so incredibly difficult, nobody managed it for three and a half centuries.
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. The proof's effect in fiction that referenced it was a mess-up not unlike that other one just a couple years prior — most works set in the future just assumed the Theorem would remain unproven for centuries, millennia, or even forever.
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 } . 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. 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. Admittedly, the complexity of the proof compared to the simplicity of the statement makes it appear inelegant. Note, however, that mathematics is full of 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.
Among remaining unsolved problems in math, the Riemann Hypothesis probably comes closest to having a story behind it nearly as good as Fermat's last theorem, though understanding its statement requires rather more background.
Not to be confused with Fermat's Little Theorem, which can be proved convincingly on the back of a postcard.
Instances of Fermat's last theorem in fiction:
- The theorem is mentioned in an episode of Yu-Gi-Oh! ARC-V, in which Yuya is challenged to prove it during a Quiz Duel. Given that he's terrible at math, he declines to answer... But really, given that the quiz only gives you five seconds to respond, it's doubtful anyone would have been able to prove the theorem in time.
- "Prove Fermat's last theorem" occurs as a problem in an Only Smart People May Pass setup in Zatch Bell!. 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.
- In Get Backers, 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 Ban in to the fact that the whole "genius dog" thing isn't a parlor trick... the dog's actually been 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.
- In the Dutch comic Storm: De Kronieken van Pandarve ^{note } , the 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, Goldbach's conjecture.
- In the My Little Pony: Friendship Is Magic fic An Academic Visit, a pony math professor named Silver Compass occasionally works on "Starswirl's Unsolved Theorem". It happens to be identical to Fermat's Last Theorem. Some human characters show him the proof, making him extremely grateful. Silver Compass notes that the mathematical concepts needed for the proof have not yet been developed in Equestria.
- Appears briefly on a blackboard in the 2000 remake of Bedazzled (2000). Satan (Elizabeth Hurley as a Hot Teacher) erases it from the list of homework assignments while commenting, "You'll never use this stuff."
- In Arthur Porges' short story "The Devil and Simon Flagg", a mathematician bets his soul that the Devil cannot prove Fermat's last theorem in twenty-four hours. He wins.
- When the general public gains access to Chronoscope technology in The Light of Other Days, a school student uses it to view Fermat's original notes and thus reconstruct the original proof.
- In the Doctor Who Missing Adventures novel Millennial Rites, it's mentioned in passing that the Corrupt Corporate Executive villain has an algebraic proof of the Theorem that he's keeping secret.
- Arthur C. Clarke'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.
- In The Millennium Trilogy, Lisbeth spends most of the second book puzzling over the Theorem. At the end of the book, she understands what he meant, but after the ending of the book, forgets it.
- Star Trek:
- In Star Trek: The Next Generation, 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 five years before Wiles' proof was released.)
- In Star Trek: Deep Space Nine, 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 Hand Wave for the TNG example, by showing that people are still working on the problem in the Star Trek universe even though it's been solved. (Another interpretation might be that the characters are still trying to find a short proof that Fermat might have come up with, without the whole fields of mathematics developed later that the Wiles proof relied on.)
- In the Doctor Who episode "The Eleventh Hour", the Doctor uses Fermat's original proof of Fermat's last theorem^{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".
- The Irish band BATS have a song about Andrew Wiles and the theorem.
- 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. That mention is edited out of the version featured on The Remains of Tom Lehrer box set to avoid dating the song.
- Shows up in Arcadia; as a joke Septimus assigns the Teen Genius Thomasina to solve it. She eventually comes to the conclusion that Fermat was Trolling. Interestingly, Arcadia was published mere months before Wiles' proof.
- The Musical Fermat's Last Tango is a No Celebrities Were Harmed 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 After Math). (Was originally to be called Proof, but premiered at the same time as Proof.)
- In Futurama World's of Tomorrow, during the first Halloween event, Farnsworth asks Bender's ghost to find Fermat's spirit and find out if he was just trolling us.
- Farnsworth: Meanwhile, as long as you're dead, be a sport and poke around the afterlife for me. See if you can find Fermat and get him to say whether he was just jerking us around.
- Irregular Webcomic! posits that Fermat was a time traveler.
- The Simpsons pulled a prank that supposedly 'proved' that Fermat's theorem was false. One episode showed a blackboard in the background that showed the equation 3987^12 + 4365^12 = 4472^12, which would prove Fermat false. The statement is false, but calculators register it as true because the numbers are so large. ^{note }