Checking Primality
Systematic algorithm:
- For prime P, for all A such that 0 < A < P
- Calculate AP-1 mod P using pow
- Check at each step of pow and at end for primality conditions
Randomized algorithm: use just one random A
If the randomized algorithm reports failure, then P really isn’t prime.
If the randomized algorithm reports success, then P might be prime.
- P is prime with probability > ¾
- Each new A has independent probability of false positive