Struct num_primes::Factorization [−][src]
pub struct Factorization;
Expand description
Prime Factorization
This struct is used to factor large numbers and return their largest prime factor
use num_primes::{Generator,Factorization};
fn main() {
// Generates New Unsighed Integer of 64 bits
let uint = Generator::new_uint(64);
// Prime Factorization
let prime_factor = Factorization::prime_factor(uint);
match prime_factor {
Some(x) => println!("Largest Prime Factor: {}",x),
None => println!("No Prime Factors Found"),
}
}
Implementations
Prime Factorization
This is a method of factoring the largest prime factors of large numbers. It is slow and should not be relied on. It can easily factor 32-bit numbers and sometimes 64-bit.
It returns as a Option<BigUint>
type
use num_primes::{Generator,Factorization};
fn main() {
// Generates New Unsighed Integer of 32 bits
let uint = Generator::new_uint(32);
// Prime Factorization
let factor = Factorization::prime_factor(uint);
match factor {
Some(factor) => println!("Largest Prime Factor: {}",factor),
None => println!("No Prime Factors Found"),
}
}