The Mathematician and the Devil (1972)

Comedy
Drama
Fantasy

A mathematician offers to sell his soul to the devil for a proof or disproof of Fermat's Last Theorem. Based on "The Devil and Simon Flagg" by Arthur Porges.