Implement mod_pow(base, exp, mod) computing base**exp % mod by square-and-multiply in O(log exp) multiplications, without calling the built-in three-argument pow. exp >= 0; mod >= 1 (anything % 1 == 0).
Then implement is_probable_prime(n) with the Fermat test for bases 2, 3, 5, 7 (return False for n < 2, True for those small primes themselves). Note that Carmichael numbers can fool it; that's expected.