Module prime

Module prime 

Source
Expand description

Implements probabilistic prime checkers.

Structsยง

BIG_1 ๐Ÿ”’
BIG_2 ๐Ÿ”’
BIG_3 ๐Ÿ”’
BIG_64 ๐Ÿ”’

Constantsยง

INCR_LIMIT ๐Ÿ”’
NUMBER_OF_PRIMES ๐Ÿ”’
PRIMES_A ๐Ÿ”’
PRIMES_B ๐Ÿ”’
PRIME_BIT_MASK ๐Ÿ”’
Records the primes < 64.
PRIME_GAP ๐Ÿ”’

Functionsยง

get_bit ๐Ÿ”’
Returns the i-th bit.
is_bit_set ๐Ÿ”’
Checks if the i-th bit is set
next_prime
Calculate the next larger prime, given a starting number n.
probably_prime
ProbablyPrime reports whether x is probably prime, applying the Miller-Rabin test with n pseudorandomly chosen bases as well as a Baillie-PSW test.
probably_prime_lucas
Reports whether n passes the โ€œalmost extra strongโ€ Lucas probable prime test, using Baillie-OEIS parameter selection. This corresponds to โ€œAESLPSPโ€ on Jacobsenโ€™s tables (link below). The combination of this test and a Miller-Rabin/Fermat test with base 2 gives a Baillie-PSW test.
probably_prime_miller_rabin
Reports whether n passes reps rounds of the Miller-Rabin primality test, using pseudo-randomly chosen bases. If force2 is true, one of the rounds is forced to use base 2.