Fermat's theorem