solution 41a -- fewer evaluations of isPrime