#prime #primality-test #miller-rabin #numbers #length #integer #checker

is_prime

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

10 releases (6 stable)

Uses old Rust 2015

2.0.9 Jul 16, 2022
2.0.8 Jul 15, 2022
2.0.7 Dec 22, 2021
1.0.5 Aug 20, 2018
0.1.3 Mar 5, 2017

#172 in Math

Download history 10/week @ 2024-01-06 4/week @ 2024-01-13 7/week @ 2024-01-20 8/week @ 2024-01-27 1/week @ 2024-02-03 11/week @ 2024-02-10 16/week @ 2024-02-17 68/week @ 2024-02-24 17/week @ 2024-03-02 36/week @ 2024-03-09 27/week @ 2024-03-16 23/week @ 2024-03-23 47/week @ 2024-03-30 27/week @ 2024-04-06 32/week @ 2024-04-13 26/week @ 2024-04-20

134 downloads per month
Used in 2 crates

GPL-3.0/GFDL-1.3

96KB
889 lines

is_prime

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

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

The documentation for this crate can be found here.

Note: This crate now uses num-bigint rather than ramp, allowing it to work with Stable rather than only Nightly

Examples

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);
}

Support

Please report any bugs or feature requests at:

Feel free to fork the repository and submit pull requests :)

Author

Alfie John <alfie@alfie.wtf>

Warranty

IT COMES WITHOUT WARRANTY OF ANY KIND.

Copyright and License

Copyright (C) 2021 by Alfie John

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License and GNU Free Documentation License as published by the Free Software Foundation, either version 3 of the GPL or 1.3 of the GFDL, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see https://www.gnu.org/licenses/.

Dependencies

~480KB
~11K SLoC