# Fermat’s Last Theorem is safe

I saw on twitter this morning a long time ago [it was a long time ago when I wrote this post but didn’t publish it] (from Jeff Atwood, of Coding Horror blog and Stack Overflow fame) the following elegantly and concisely stated counter-example that would – if true – disprove perhaps the most famous of mathematical theorems, Fermat’s Last Theorem (FLT):

1782^12 + 1841^12 = 1922^12

Wow! A counter-example for FLT. A theorem I’ve known about since I was a kid. One counter-example is all it takes to disprove the whole deal.

Fermat’s theorem states that the equation an + bn = cn has no solutions for integer n > 2, and integers a, b, and c not equal to zero. For n = 2 we have many solutions (Pythagorean triples), but none for n > 2. Nor should we, according to English mathematician Andrew Wiles, who proved FLT in 1995.

Until now. Or do we? The equation Jeff posted is a little awkward to validate since most calculators cannot handle numbers this size at full precision. They appear equal with a normal calculator – due to precision limits (round-off errors). Same problem with Excel.

So, since I’ve recently started playing with F#, I put together a trivial F# program (included below) to show the math at full precision, with the following results:

1782^12 + 1841^12 = 2541210258614589176288669958142428526657
and
1922^12 = 2541210259314801410819278649643651567616
which differ by
700212234530608691501223040959

So Fermat is safe. Saved by F#. 🙂 But don’t feel bad if you fell for it – just be glad you knew what it meant. Bonus if  you noticed it on The Simpsons or Futurama.