Skip to content

Commit

Permalink
Move trait impl up in fermats factorization
Browse files Browse the repository at this point in the history
  • Loading branch information
hesampakdaman committed Apr 9, 2024
1 parent c73ac86 commit e86828d
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/algorithms/fermats_factorization_method.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@ impl Factorize for FermatsFactorizationMethod {
}
}

impl PrimeFactorization for FermatsFactorizationMethod {
fn prime_factorization(n: &U512) -> Vec<U512> {
orchestration::FactorizeRecursiveWith::<Self, MillerRabin>::prime_factorization(n)
}
}

fn ceil_sqrt(n: &U512) -> U512 {
if is_perfect_square(n) {
n.sqrt()
Expand All @@ -32,12 +38,6 @@ fn is_perfect_square(n: &U512) -> bool {
sqrt * sqrt == *n
}

impl PrimeFactorization for FermatsFactorizationMethod {
fn prime_factorization(n: &U512) -> Vec<U512> {
orchestration::FactorizeRecursiveWith::<Self, MillerRabin>::prime_factorization(n)
}
}

#[cfg(test)]
mod tests {
use super::*;
Expand Down

0 comments on commit e86828d

Please sign in to comment.