Primality is a Golang library for determining whether any given integer
math/big
library.
The two methods provided are the Miller-Rabin and AKS primality test the former being probabilistic and the latter deterministic, meaning that the Miller-Rabin primality test doesn't guarantee 100% accuracy in certain situations. Whereas the AKS primality test is always 100% accurate - but a lot slower on larger integers.
- Highly accurate probabilistic primality test
- 25 rounds and force usage of base 2 recommended for near 100% accuracy
- Arbitrarily large integer support (
big.Int
) -
time complexity (assuming big.Int
operations arewhere is the number of repetitions and the number of trailing zeros on , the number being tested - otherwise it is related to the operations of big.Int
integers anditself. - As a prime must be odd
meaning the time complexity in its worst case is with 25 repetitions.
- As a prime must be odd
- Deterministic primality test
- Slow overall - but guarantees 100% a valid outcome
int
support only
- Improve speed of the AKS method
- Specifically step 5 but overall it is slow
- Make the AKS method work on arbitrarily sized integers
- use
big.Int
s overint
s
- use
- Determine the true time and space complexities for both methods