SICP Exercise 1.28: The Miller-Rabin test