pub struct Factors<T: PrimitiveUnsigned, const N: usize> { /* private fields */ }Expand description
A struct that contains the prime factorization of an integer. See implementations of the
Factor trait for more information.
Trait Implementations§
impl<T: Eq + PrimitiveUnsigned, const N: usize> Eq for Factors<T, N>
Source§impl<T: PrimitiveUnsigned, const N: usize> IntoIterator for Factors<T, N>
impl<T: PrimitiveUnsigned, const N: usize> IntoIterator for Factors<T, N>
impl<T: PartialEq + PrimitiveUnsigned, const N: usize> StructuralPartialEq for Factors<T, N>
Source§impl<T: PrimitiveUnsigned, const N: usize> ToLatex for Factors<T, N>
impl<T: PrimitiveUnsigned, const N: usize> ToLatex for Factors<T, N>
Source§fn fmt_latex(&self, f: &mut Formatter<'_>) -> Result
fn fmt_latex(&self, f: &mut Formatter<'_>) -> Result
Writes a Factors as a LaTeX math-mode fragment.
The fragment is the factorization written out as a product of prime powers, so the
factorization of 90 becomes 2 \times 3^2 \times 5. An exponent of 1 is left off, as it is
when a factorization is written by hand.
The factorization of 1 has no factors at all, and becomes 1: the empty product, which is
what it multiplies out to.
§Worst-case complexity
$T(n) = O(n)$
$M(n) = O(1)$
where $T$ is time, $M$ is additional memory, and $n$ is the number of distinct prime factors.
§Examples
use malachite_base::num::factorization::traits::Factor;
use malachite_base::strings::latex::ToLatex;
assert_eq!(1u32.factor().to_latex_string(), "1");
assert_eq!(2u32.factor().to_latex_string(), "2");
assert_eq!(4u32.factor().to_latex_string(), r"2^2");
assert_eq!(90u32.factor().to_latex_string(), r"2 \times 3^2 \times 5");
assert_eq!(1024u32.factor().to_latex_string(), r"2^{10}");| value | fragment | renders as |
|---|---|---|
1u32.factor() | 1 | $1$ |
2u32.factor() | 2 | $2$ |
4u32.factor() | 2^2 | $2^2$ |
90u32.factor() | 2 \times 3^2 \times 5 | $2 \times 3^2 \times 5$ |
1024u32.factor() | 2^{10} | $2^{10}$ |
Source§impl<T: PrimitiveUnsigned, const N: usize> ToTypst for Factors<T, N>
impl<T: PrimitiveUnsigned, const N: usize> ToTypst for Factors<T, N>
Source§fn fmt_typst(&self, f: &mut Formatter<'_>) -> Result
fn fmt_typst(&self, f: &mut Formatter<'_>) -> Result
Writes a Factors as a Typst math-mode fragment.
The fragment is the factorization written out as a product of prime powers, so the
factorization of 90 becomes 2 times 3^2 times 5. An exponent of 1 is left off, as it is
when a factorization is written by hand.
The factorization of 1 has no factors at all, and becomes 1: the empty product, which is
what it multiplies out to.
§Worst-case complexity
$T(n) = O(n)$
$M(n) = O(1)$
where $T$ is time, $M$ is additional memory, and $n$ is the number of distinct prime factors.
§Examples
use malachite_base::num::factorization::traits::Factor;
use malachite_base::strings::typst::ToTypst;
assert_eq!(1u32.factor().to_typst_string(), "1");
assert_eq!(2u32.factor().to_typst_string(), "2");
assert_eq!(4u32.factor().to_typst_string(), "2^2");
assert_eq!(90u32.factor().to_typst_string(), "2 times 3^2 times 5");
assert_eq!(1024u32.factor().to_typst_string(), "2^(10)");| value | fragment |
|---|---|
1u32.factor() | 1 |
2u32.factor() | 2 |
4u32.factor() | 2^2 |
90u32.factor() | 2 times 3^2 times 5 |
1024u32.factor() | 2^(10) |
Auto Trait Implementations§
impl<T, const N: usize> Freeze for Factors<T, N>
impl<T, const N: usize> RefUnwindSafe for Factors<T, N>
impl<T, const N: usize> Send for Factors<T, N>
impl<T, const N: usize> Sync for Factors<T, N>
impl<T, const N: usize> Unpin for Factors<T, N>
impl<T, const N: usize> UnsafeUnpin for Factors<T, N>
impl<T, const N: usize> UnwindSafe for Factors<T, N>
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<T, U> ImaginaryInto<U> for Twhere
U: ImaginaryFrom<T>,
impl<T, U> ImaginaryInto<U> for Twhere
U: ImaginaryFrom<T>,
fn imaginary_into(self) -> U
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more