Fermat's Last Theorem in fiction

The problem in number theory known as "Fermat's Last Theorem" has repeatedly received attention in fiction and popular culture. It was proved by Andrew Wiles in 1994.

Prose fiction

 * The theorem plays a key role in the 1948 mystery novel Murder by Mathematics by Hector Hawton.
 * Arthur Porges' short story "The Devil and Simon Flagg" features a mathematician who bargains with the Devil that the latter cannot produce a proof of Fermat's Last Theorem within twenty-four hours. The devil is not successful and is last seen beginning a collaboration with the hero. The story was first published in 1954 in The Magazine of Fantasy and Science Fiction.
 * In Douglas Hofstadter's 1979 book Gödel, Escher, Bach, the statement, "I have discovered a truly remarkable proof of this theorem which this margin is too small to contain" is repeatedly rephrased and satirized, including a pun on "fermata".
 * In Robert Forward's 1984/1985 science fiction novel Rocheworld, Fermat's Last Theorem is unproved far enough into the future for interstellar explorers to describe it to one of the mathematically inclined natives of another star system, who finds a proof.
 * In the 2003 book The Oxford Murders by Guillermo Martinez, Wiles's announcement in Cambridge of his proof of Fermat's Last Theorem forms a peripheral part of the action.
 * In Stieg Larsson's 2006 book The Girl Who Played with Fire, the main character Lisbeth Salander is mesmerized by the theorem. Fields medalist Timothy Gowers criticized Larsson's portrayal of the theorem as muddled and confused.
 * In Jasper Fforde's 2007 book First Among Sequels, 9-year-old Tuesday Next, seeing the equation on the sixth-form's math classroom's chalkboard, and thinking it homework, finds a simple counterexample.
 * Arthur C. Clarke and Frederik Pohl's 2008 novel The Last Theorem tells of the rise to fame and world prominence of a young Sri Lankan mathematician who devises an elegant proof of the theorem.

Television

 * "The Royale", an episode (first aired 27 March 1989) of Star Trek: The Next Generation, begins with Picard attempting to solve the puzzle in his ready room; he remarks to Riker that the theorem had remained unproven for 800 years. The captain ends the episode with the line "Like Fermat's theorem, it is a puzzle we may never solve." Wiles' proof was released five years after the episode aired. The theorem was again mentioned in a subsequent Star Trek: Deep Space Nine episode called "Facets" in June 1995, in which Jadzia Dax comments that one of her previous hosts, Tobin Dax, had "the most original approach to the proof since Wiles over 300 years ago".
 * A sum, proved impossible by the theorem, appears in the 1995 episode of The Simpsons, "Treehouse of Horror VI". In the three-dimensional world in "Homer3", the equation $$1782^{12} + 1841^{12} = 1922^{12}$$ is visible, just as the dimension begins to collapse. The joke is that the twelfth root of the sum does evaluate to 1922 due to rounding errors when entered into most handheld calculators. A second "counterexample" appeared in the 1998 episode, "The Wizard of Evergreen Terrace": $$3987^{12} + 4365^{12} = 4472^{12}$$, again forming a near-miss that appears true when evaluated on a handheld calculator.
 * In the Doctor Who 2010 episode "The Eleventh Hour", the Doctor transmits a proof of Fermat's Last Theorem by typing it in just a few seconds on a laptop, to prove his genius to a collection of world leaders discussing the latest threat to the human race.

Films

 * Fermat's equation appears in the 2000 film Bedazzled with Elizabeth Hurley and Brendan Fraser. Hurley plays the devil who, in one of her many forms, appears as a school teacher who assigns Fermat's Last Theorem as a homework problem.
 * In the 2008 film adaptation of The Oxford Murders, Fermat's Last Theorem became "Bormat's".

Theater

 * In Tom Stoppard's 1993 play Arcadia, Septimus Hodge poses the problem of proving Fermat's Last Theorem to the precocious Thomasina Coverly (who is perhaps a mathematical prodigy), in an attempt to keep her busy. Thomasina responds that Fermat had no proof and claimed otherwise in order to torment later generations. Shortly after Arcadia opened in London, Andrew Wiles announced his proof of Fermat's Last Theorem, a coincidence of timing that resulted in news stories about the proof quoting Stoppard.
 * Fermat's Last Tango is a 2000 stage musical by Joanne Sydney Lessner and Joshua Rosenblum. Protagonist "Daniel Keane" is a fictionalized Andrew Wiles. The characters include Fermat, Pythagoras, Euclid, Newton, and Gauss, the singing, dancing mathematicians of "the aftermath".