pub struct PrimeFactors { /* private fields */ }Expand description
The prime factorization of an integer, represented as a list of prime factors with their exponents.
Implementations§
Source§impl PrimeFactors
impl PrimeFactors
Sourcepub fn value(&self) -> u128
pub fn value(&self) -> u128
Reconstruct the original integer from its prime factorization. An empty factorization yields 1 (the empty product).
Sourcepub fn count_factors(&self) -> u32
pub fn count_factors(&self) -> u32
Return the total number of prime factors (counting multiplicities).
pub fn is_empty(&self) -> bool
pub fn is_prime(&self) -> bool
Sourcepub fn to_vec(&self) -> Vec<u128>
pub fn to_vec(&self) -> Vec<u128>
Expand the factorization into a flat vector of prime factors.
Sourcepub fn gcd(&self, other: &PrimeFactors) -> PrimeFactors
pub fn gcd(&self, other: &PrimeFactors) -> PrimeFactors
Compute the GCD of two prime factorizations by intersecting common factors. Returns an empty result if either factorization is empty.
Sourcepub fn has_any_factor(n: u128) -> bool
pub fn has_any_factor(n: u128) -> bool
Check if n has any non-trivial factor using wheel factorization. Returns true as soon as any factor is found, without full decomposition.
Trait Implementations§
Source§impl Clone for PrimeFactors
impl Clone for PrimeFactors
Source§fn clone(&self) -> PrimeFactors
fn clone(&self) -> PrimeFactors
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for PrimeFactors
impl Debug for PrimeFactors
Source§impl Display for PrimeFactors
impl Display for PrimeFactors
Source§impl<'a> IntoIterator for &'a PrimeFactors
Iterate over the prime factors with their exponents.
impl<'a> IntoIterator for &'a PrimeFactors
Iterate over the prime factors with their exponents.
Source§impl IntoIterator for PrimeFactors
Consume and iterate over the prime factors with their exponents.
impl IntoIterator for PrimeFactors
Consume and iterate over the prime factors with their exponents.
Source§impl Ord for PrimeFactors
impl Ord for PrimeFactors
Source§fn cmp(&self, other: &PrimeFactors) -> Ordering
fn cmp(&self, other: &PrimeFactors) -> Ordering
1.21.0 · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
Source§impl PartialEq for PrimeFactors
impl PartialEq for PrimeFactors
Source§impl PartialOrd for PrimeFactors
impl PartialOrd for PrimeFactors
impl Eq for PrimeFactors
impl StructuralPartialEq for PrimeFactors
Auto Trait Implementations§
impl Freeze for PrimeFactors
impl RefUnwindSafe for PrimeFactors
impl Send for PrimeFactors
impl Sync for PrimeFactors
impl Unpin for PrimeFactors
impl UnsafeUnpin for PrimeFactors
impl UnwindSafe for PrimeFactors
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more