Check fermat's theorem - solution to Ex.5.3