- galois.is_prime(n: int) bool
Determines if
is prime.See also
Notes¶
This algorithm will first run Fermat’s primality test to check
for compositeness, seefermat_primality_test()
. If it determines is composite, the function will quickly return.If Fermat’s primality test returns
True
, then could be prime or pseudoprime. If so, then the algorithm will run 10 rounds of Miller-Rabin’s primality test, seemiller_rabin_primality_test()
. With this many rounds, a result ofTrue
should have high probability of being a true prime, not a pseudoprime.Examples¶
In [1]: galois.is_prime(13) Out[1]: True In [2]: galois.is_prime(15) Out[2]: False
The algorithm is also efficient on very large
.In [3]: galois.is_prime(1000000000000000035000061) Out[3]: True