Crate is_prime[][src]

Expand description

Fast arbitrary length prime number checker using the Miller-Rabin primality test algorithm

This module implements the Miller-Rabin primality test algorithm. Given an arbitrary length integer specified within a string, apply the probabilistic algorithm to check if the integer may be prime.


extern crate is_prime;

use is_prime::*;

fn main() {
    // The first RSA Prime
    assert!(is_prime("37975227936943673922808872755445627854565536638199") == true);

    // The first RSA Prime + 1
    assert!(is_prime("37975227936943673922808872755445627854565536638200") == false);


Tests if the given integer within a string is prime