Skip to content

Commit

Permalink
Use TWO and ONE instead of U512::from(..)
Browse files Browse the repository at this point in the history
  • Loading branch information
hesampakdaman committed Apr 28, 2024
1 parent ff76a63 commit 934025c
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/algorithms/pollards_rho.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ pub struct PollardsRho;

impl Factorize for PollardsRho {
fn factorize(n: &U512) -> U512 {
let init = U512::from(2u8);
let init = U512::TWO;
let pseudorandom_fn = utils::generate_pseudorandom_fn(n);
let finished = move |x: &U512, y: &U512| x.abs_diff(*y).gcd(n) != U512::from(1u8);
let finished = move |x: &U512, y: &U512| x.abs_diff(*y).gcd(n) != U512::ONE;
let (tortoise, hare) = utils::floyds_cycle_detection(init, &pseudorandom_fn, &finished);
hare.abs_diff(tortoise).gcd(n)
}
Expand Down
2 changes: 1 addition & 1 deletion src/algorithms/pollards_rho/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,5 @@ pub fn generate_pseudorandom_fn(n: &'_ U512) -> impl Fn(&U512) -> U512 + '_ {
}

fn random_integer(bound: &U512) -> U512 {
rand::thread_rng().gen_range(U512::from(2u8)..*bound)
rand::thread_rng().gen_range(U512::TWO..*bound)
}

0 comments on commit 934025c

Please sign in to comment.