-
-
Save hauleth/cba01660a83ab8c967a2 to your computer and use it in GitHub Desktop.
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
fn witness(num: BigInt, a: BigInt, d: &BigInt, s: usize) -> Result { | |
let mut x = (&a).pow_mod(d, &num); | |
if x == one() || x == (&num - BigInt::one()) { return Result::Composite } | |
for _ in 0..s { | |
x = (&x * &x) % # | |
if x == one() { return Result::Composite } | |
if x == (&num - BigInt::one()) { return Result::PropablyPrime } | |
} | |
Result::Composite | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment