pub fn pollard_rho_get_one_factor(number: u64, seed: &mut u32, check_is_prime: bool) -> u64 {
    // LCG parameters from wikipedia
    let mut rng = LinearCongruenceGenerator::new(1103515245, 12345, *seed);
    if number <= 1 {
        return number;
    }
    if check_is_prime {
        let mut bases = vec![2u64, 3, 5, 7];
        if number > 3_215_031_000 {
            bases.append(&mut vec![11, 13, 17, 19, 23, 29, 31, 37]);
        }
        if miller_rabin(number, &bases) == 0 {
            return number;
        }
    }
    let mut factor = 1u64;
    while factor == 1 || factor == number {
        let x = rng.get_64bits();
        let c = rng.get_64bits();
        factor = pollard_rho_customizable(
            number,
            (x % (number - 3)) + 2,
            (c % (number - 2)) + 1,
            32,
            1 << 18, // This shouldn't take much longer than number ^ 0.25
        );
        // These numbers were selected based on local testing.
        // For specific applications there maybe better choices.
    }
    *seed = rng.state;
    factor
}
/*
Note: using this function with `check_is_prime` = false
and a prime number will result in an infinite loop.

RNG's internal state is represented as `seed`. It is
advisable (but not mandatory) to reuse the saved seed value
In subsequent calls to this function.
 */
using this function with `check_is_prime` = false
and a prime number will result in an infinite loop.

RNG's internal state is represented as `seed`. It is
advisable (but not mandatory) to reuse the saved seed value
In subsequent calls to this function.
using this function with ` check_is_prime ` = false and a prime number will result in an infinite loop . RNG ' s internal state is represented as ` seed ` . It is advisable ( but not mandatory ) to reuse the saved seed value In subsequent calls to this function .
pub fn pollard_rho_get_one_factor(number: u64, seed: &mut u32, check_is_prime: bool) -> u64 {
    // LCG parameters from wikipedia
    let mut rng = LinearCongruenceGenerator::new(1103515245, 12345, *seed);
    if number <= 1 {
        return number;
    }
    if check_is_prime {
        let mut bases = vec![2u64, 3, 5, 7];
        if number > 3_215_031_000 {
            bases.append(&mut vec![11, 13, 17, 19, 23, 29, 31, 37]);
        }
        if miller_rabin(number, &bases) == 0 {
            return number;
        }
    }
    let mut factor = 1u64;
    while factor == 1 || factor == number {
        let x = rng.get_64bits();
        let c = rng.get_64bits();
        factor = pollard_rho_customizable(
            number,
            (x % (number - 3)) + 2,
            (c % (number - 2)) + 1,
            32,
            1 << 18, // This shouldn't take much longer than number ^ 0.25
        );
        // These numbers were selected based on local testing.
        // For specific applications there maybe better choices.
    }
    *seed = rng.state;
    factor
}
pub fn pollard_rho_get_one_factor ( number : u64 , seed : & mut u32 , check_is_prime : bool ) -> u64 { // LCG parameters from wikipedia let mut rng = LinearCongruenceGenerator :: new ( 1103515245 , 12345 , * seed ) ; if number <= 1 { return number ; } if check_is_prime { let mut bases = vec ! [ 2u64 3 5 7 ] ; if number > 3_215_031_000 { bases . append ( & mut vec ! [ 11 13 17 19 23 29 31 37 ] ) ; } if miller_rabin ( number , & bases ) == 0 { return number ; } } let mut factor = 1u64 ; while factor == 1 || factor == number { let x = rng . get_64bits ( ) ; let c = rng . get_64bits ( ) ; factor = pollard_rho_customizable ( number , ( x % ( number - 3 ) ) + 2 , ( c % ( number - 2 ) ) + 1 , 32 , 1 << 18 , // This shouldn't take much longer than number ^ 0.25 ) ; // These numbers were selected based on local testing. // For specific applications there maybe better choices. } * seed = rng . state ; factor }
Note: using this function with `check_is_prime` = false
and a prime number will result in an infinite loop.
Note : using this function with ` check_is_prime ` = false and a prime number will result in an infinite loop .
number
u64
seed
&mut u32
check_is_prime
bool
number
u64
seed
&mut u32
check_is_prime
bool