pub struct Factorization { /* private fields */ }
Expand description

A prime power decomposition of a positive integer.

Implementations§

source§

impl Factorization

source

pub const fn new(factors: &'static [(u128, usize)]) -> Factorization

Creates a new factorization from the given prime powers.

source

pub fn maximal_divisors<const L: usize>( &self, l: u128 ) -> impl Iterator<Item = [usize; L]>

Returns an Iterator yielding the maximal divisors of the number represented by this Factorization below l; that is, if this Factorization represents the number $n$, then this Iterator yields vectors representing all elements $d$ satisfying these properties:

  • $d | n$,
  • $d \leq l$, and
  • there are no elements $k | n$ such that $d | k$ and $k \leq l$.

The iterator cannot outlive the Factorization, although the vectors yielded by it may.

source

pub const fn is_empty(&self) -> bool

True if there the factorization represents 1. False otherwise.

source

pub const fn factor(&self, i: usize) -> u128

Returns the prime power factor represented by prime number i, $p_i^{t_i}$. This method will panic if i is out of bounds.

source

pub const fn factors(&self) -> &'static [(u128, usize)]

Gets the prime powers as an array. The first element of each entry is the prime, and the second is the power.

source

pub const fn value(&self) -> u128

Returns the positive integer represented by this Factorization.

source

pub fn from_powers(&self, ds: &[usize]) -> u128

Converts an array of powers on the prime factors into an integer.

source

pub fn exponents(&self) -> Box<[usize]>

Returns the exponents on the factorization.

source

pub const fn len(&self) -> usize

Returns the number of prime factors in the factorization.

source

pub const fn tau(&self) -> u128

Returns $\tau$(&self), the number of divisors of this integer. See OEIS sequence A000005.

source

pub const fn phi(&self) -> u128

Returns $\phi$(&self), the Euler totient function of this integer. The totient function $\phi(n)$ is the number of integers $\leq n$ and relatively prime to $n$. See OEIS sequence A000010.

Trait Implementations§

source§

impl Clone for Factorization

source§

fn clone(&self) -> Factorization

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for Factorization

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Index<usize> for Factorization

§

type Output = (u128, usize)

The returned type after indexing.
source§

fn index(&self, index: usize) -> &(u128, usize)

Performs the indexing (container[index]) operation. Read more
source§

impl PartialEq<Factorization> for Factorization

source§

fn eq(&self, other: &Factorization) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Eq for Factorization

source§

impl StructuralEq for Factorization

source§

impl StructuralPartialEq for Factorization

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

§

impl<T> Pointable for T

§

const ALIGN: usize = mem::align_of::<T>()

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

impl<T> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

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

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.