Crate machine_prime

source ·
Expand description

An efficient public domain library to prove primality in minimal time for all 64-bit integers. Intended to be usable across any machines that support unsigned integer arithmetic and callable from any language that supports C-bindings. The algorithms may change in the future, however the API and worst-case complexity limits will not.

For efficiency reasons two functions are provided, is_prime and is_prime_wc. is_prime is the general primality test used for arbitrary integers, while is_prime_wc is the variant intended to be used as a helper function in other functions. Be wary that is_prime_wc is slower and does not always produce correct results, unless used against composites with large factors or unknown primes. See the documentation for it to see the errors to avoid.

Functions

  • Primality testing optimized for the average case in the interval 0;2^64.
  • Primality testing optimized for the worst case of composites with large factors or primes