[][src]Struct num_primes::Factorization

pub struct Factorization;

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

impl Factorization[src]

pub fn prime_factor(mut n: BigUint) -> Option<BigUint>[src]

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"),
    }
}

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.