Change the implementation of is_prime_ex.