faster method
faster method

a number is only prime if it is of the form 6k ± 1. So we test if n is of the form 6k±1 and then test if it has factors (not prime) or not (prime).
MagikCow/Primes-Library-Python