Skip to main content

PrimeFactorization

Trait PrimeFactorization 

Source
pub trait PrimeFactorization<T> {
    // Required method
    fn factors(&self, x: T) -> Vec<(T, u32)>;
}
Expand description

素因数分解

§Examples

use prime_factorization::{ByLeastPrimeFactors, PrimeFactorization, TrialDivision};

let trial_div = TrialDivision::new();
let lpf = ByLeastPrimeFactors::new(90);

// 90 = 2 * 3 * 3 * 5
assert_eq!(trial_div.factors(90_u32), vec![(2, 1), (3, 2), (5, 1)]);
assert_eq!(lpf.factors(90), vec![(2, 1), (3, 2), (5, 1)]);

Required Methods§

Source

fn factors(&self, x: T) -> Vec<(T, u32)>

x の (素因数, べき) のベクタを返します

Implementors§