fn rabin_miller(proposal: &BigUint, t: u32) -> bool {
    // Needed constants
    let (zero, one, two) = (&BigUint::zero(), &BigUint::from(1 as u32), &BigUint::from(2 as u32));
    
    // If proposal <= 1 Rabin-Miller has to fail.
    if proposal.clone() <= one.to_owned() {return false};
    // If proposal != 2 and modulus 2 = 0, Rabin-Miller fails.
    if proposal.clone() != two.to_owned() && proposal.clone() % two == zero.to_owned() {return false};
    // Getting exp to execute mulmod.
    let (s,d) = refactor(proposal);

    let mut counter = 0;
    while counter < t {
        // Gen rand biguint from a range (2, proposal-2)
        let mut rng = rand::thread_rng();
        let a = rng.gen_biguint_range(two , &(proposal - two) );

        let mut x = mod_exp_pow(&a, &d, proposal);
        if x != one.to_owned() && x != proposal.to_owned() - one {
            let mut i = zero.clone();
            loop {
                x = mod_exp_pow(&x, &two, proposal);
                if x == proposal.to_owned() - one {break;}
                if x == one.to_owned() || i >= s.clone()- one{return false;};
                
                i = i.clone() + one;
            }
        }
        counter +=2;
    }  
    true
}
// Rabin-Miller is a probabilistic algorithm that checks if a number is prime based on Riemmann's conjecture.
// Implemented from psoudocode found on: https://en.wikibooks.org/wiki/Algorithm_Implementation/Mathematics/Primality_Testing 
// The function recieves a prime proposal and the threshold probability of a false positive
// due to composite numbers reported as primes.
// The pobability of a false positive is 4^-threshold. With t=9 => P(false_positive) = 3/1_000_000 
Rabin-Miller is a probabilistic algorithm that checks if a number is prime based on Riemmann's conjecture.
Rabin - Miller is a probabilistic algorithm that checks if a number is prime based on Riemmann ' s conjecture .
fn rabin_miller(proposal: &BigUint, t: u32) -> bool {
    // Needed constants
    let (zero, one, two) = (&BigUint::zero(), &BigUint::from(1 as u32), &BigUint::from(2 as u32));
    // If proposal <= 1 Rabin-Miller has to fail.
    if proposal.clone() <= one.to_owned() {return false};
    // If proposal != 2 and modulus 2 = 0, Rabin-Miller fails.
    if proposal.clone() != two.to_owned() && proposal.clone() % two == zero.to_owned() {return false};
    // Getting exp to execute mulmod.
    let (s,d) = refactor(proposal);
    let mut counter = 0;
    while counter < t {
        // Gen rand biguint from a range (2, proposal-2)
        let mut rng = rand::thread_rng();
        let a = rng.gen_biguint_range(two , &(proposal - two) );
        let mut x = mod_exp_pow(&a, &d, proposal);
        if x != one.to_owned() && x != proposal.to_owned() - one {
            let mut i = zero.clone();
            loop {
                x = mod_exp_pow(&x, &two, proposal);
                if x == proposal.to_owned() - one {break;}
                if x == one.to_owned() || i >= s.clone()- one{return false;};
                i = i.clone() + one;
            }
        }
        counter +=2;
    }  
    true
}
fn rabin_miller ( proposal : & BigUint , t : u32 ) -> bool { // Needed constants let ( zero , one , two ) = ( & BigUint :: zero ( ) , & BigUint :: from ( 1 as u32 ) , & BigUint :: from ( 2 as u32 ) ) ; // If proposal <= 1 Rabin-Miller has to fail. if proposal . clone ( ) <= one . to_owned ( ) { return false } ; // If proposal != 2 and modulus 2 = 0, Rabin-Miller fails. if proposal . clone ( ) != two . to_owned ( ) && proposal . clone ( ) % two == zero . to_owned ( ) { return false } ; // Getting exp to execute mulmod. let ( s , d ) = refactor ( proposal ) ; let mut counter = 0 ; while counter < t { // Gen rand biguint from a range (2, proposal-2) let mut rng = rand :: thread_rng ( ) ; let a = rng . gen_biguint_range ( two , & ( proposal - two ) ) ; let mut x = mod_exp_pow ( & a , & d , proposal ) ; if x != one . to_owned ( ) && x != proposal . to_owned ( ) - one { let mut i = zero . clone ( ) ; loop { x = mod_exp_pow ( & x , & two , proposal ) ; if x == proposal . to_owned ( ) - one { break ; } if x == one . to_owned ( ) || i >= s . clone ( ) - one { return false ; } ; i = i . clone ( ) + one ; } } counter += 2 ; } true }
Rabin-Miller is a probabilistic algorithm that checks if a number is prime based on Riemmann's conjecture.
Rabin - Miller is a probabilistic algorithm that checks if a number is prime based on Riemmann ' s conjecture .
proposal
&BigUint
t
u32