P027: improved checkPrime