Undoubtedly, prime numbers are crucial elements for many real-world applications, especially cryptography (see the RSA repository). One of the many problems related to prime numbers is determining whether a given number is prime (a primality test) or, equivalently, whether it is composite (a compositeness test). Deterministic methods exist, but none of them are efficient for large numbers. Therefore, practical implementations rely on probabilistic tests, which are highly efficient and can identify composite numbers with a high probabilities depending on the test used.
This method is inspired by Fermat's little theorem (and generally, Euler's theorem) which states that:
Therefore, a number for which this property doesn't hold for some base
A witness according to Miller-Rabin test is a base
No analogeous numbers to Carmichael numbers exists for this test, that is, for any composite number
For any composite number, at least
This repository contains
-
Functions to test primality of a given number based on both Fermat and Miller-Rabi methods.
-
Functions to generate prime numbers of given bit-length using the two methods.
-
A report explaining both methods with much more depth.
-
Some comparative scripts and figures.
-
Other methods will be added and further discussions will be made.
Marouf Haider
For any questions, remarks, or suggestions, please contact me here: ensmmarouf@gmail.com
- Conrad, Keith. “THE MILLER–RABIN TEST.” (2017).
- Koblitz, N. (1987). Primality and Factoring. In: A Course in Number Theory and Cryptography. Graduate Texts in Mathematics, vol 114. Springer, New York, NY. https://doi.org/10.1007/978-1-4684-0310-7_5