This Rust library provides various prime factorization algorithms for integers. Choose the most suitable algorithm for your needs.
The following prime factorization algorithms:
- Trial Division
- Pollard's Rho Algorithm
- Fermat's Factorization Method
- Euler's Factorization Method (TODO)
- Special Number Field Sieve (TODO)
- Dixon's Algorithm (TODO)
- Continued Fraction Factorization (TODO)
- Quadratic Sieve (TODO)
- Rational Sieve (TODO)
- General Number Field Sieve (TODO)
- Shanks's Square Form Factorization (TODO)
- Pollard's p-1 Factorization
To use this library, add it as a dependency in your Cargo.toml file:
[dependencies]
pfact = { path = "path/to/pfact"}
Then, import the desired algorithm(s) in your Rust source code:
extern crate pfact;
use pfact::trial_division;
use pfact::pollards_rho;
// ... import other algorithms as needed
To factorize a number using a specific algorithm:
use num_bigint::BigUint;
use pfact::trial_division;
fn main() {
let number: BigUint = BigUint::from(1234567u32);
let factor = trial_division::get_lowest_prime_factor(number);
println!("Prime factors: {}", factor);
}
// Replace trial_division with the desired algorithm in the example above.