-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from evrhines/fix_primality_tests
Fix broken miller-rabin primality test
- Loading branch information
Showing
2 changed files
with
20 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
use num_bigint::BigUint; | ||
use num_primes::Verification; | ||
|
||
#[test] | ||
fn primality_test() { | ||
let big_prime = BigUint::parse_bytes(b"169511182982703321453314585423962898651587669459838234386506572286328885534468792292646838949809616446341407457141008401355628947670484184607678853094537849610289912805960069455687743151708433319901176932959509872662610091644590437761688516626993416011399330087939042347256922771590903190536793274742859624657", 10).unwrap(); | ||
let med_prime = BigUint::parse_bytes(b"17957", 10).unwrap(); | ||
let small_prime = BigUint::parse_bytes(b"5", 10).unwrap(); | ||
|
||
assert!(Verification::is_prime(&small_prime)); | ||
assert!(Verification::is_prime(&med_prime)); | ||
assert!(Verification::is_prime(&big_prime)); | ||
} |