No, it is not the same: your routine makes use of the fact that all primes greater than 2 are of the form 2k+1; this routine makes use of the fact that all primes greater than 3 are of the forms 6k-1 or 6k+1. On average, this routine makes two-thirds as many checks for divisibility.Originally Posted byflp1969

That's what I wrote in post #25. I think it was the approach I took some years (over a decade?) back when someone posted some primality testing challenge here, but my solution wasn't very good compared with some others as it wasn't tailored to the challenge.Originally Posted byflp1969