The tale of Fermat's last theorem took hundreds of years and included tantalising twists, disappointing errors and a contribution from the most unlikely cartoon mathematician imaginable