Added fermat test based on SICP 1.2.6 for problem 31