Trait malachite_base::num::arithmetic::traits::CheckedPrimorial
source · pub trait CheckedPrimorial: Sized {
// Required methods
fn checked_primorial(n: u64) -> Option<Self>;
fn checked_product_of_first_n_primes(n: u64) -> Option<Self>;
}
Required Methods§
fn checked_primorial(n: u64) -> Option<Self>
fn checked_product_of_first_n_primes(n: u64) -> Option<Self>
Object Safety§
Implementations on Foreign Types§
source§impl CheckedPrimorial for u8
impl CheckedPrimorial for u8
source§fn checked_primorial(n: u64) -> Option<u8>
fn checked_primorial(n: u64) -> Option<u8>
Computes the primorial of a number: the product of all primes less than or equal to it.
The
checked_product_of_first_n_primes
function is similar; it computes the primorial of the $n$th prime.
If the input is too large, the function returns None
.
$$
f(n) = \begin{cases}
\operatorname{Some}(n\#) & \text{if} \quad n\# < 2^W, \\
\operatorname{None} & \text{if} \quad n\# \geq 2^W,
\end{cases}
$$
where $W$ is Self::WIDTH
.
§Worst-case complexity
Constant time and additional memory.
§Examples
See here.
source§fn checked_product_of_first_n_primes(n: u64) -> Option<u8>
fn checked_product_of_first_n_primes(n: u64) -> Option<u8>
Computes the product of the first $n$ primes.
The checked_primorial
function is similar;
it computes the product of all primes less than or equal to $n$.
If the input is too large, the function returns None
.
$$
f(n) = \begin{cases}
\operatorname{Some}(p_n\#) & \text{if} \quad p_n\# < 2^W, \\
\operatorname{None} & \text{if} \quad p_n\# \geq 2^W,
\end{cases}
$$
where $W$ is Self::WIDTH
.
§Worst-case complexity
Constant time and additional memory.
§Examples
See here.
source§impl CheckedPrimorial for u16
impl CheckedPrimorial for u16
source§fn checked_primorial(n: u64) -> Option<u16>
fn checked_primorial(n: u64) -> Option<u16>
Computes the primorial of a number: the product of all primes less than or equal to it.
The
checked_product_of_first_n_primes
function is similar; it computes the primorial of the $n$th prime.
If the input is too large, the function returns None
.
$$
f(n) = \begin{cases}
\operatorname{Some}(n\#) & \text{if} \quad n\# < 2^W, \\
\operatorname{None} & \text{if} \quad n\# \geq 2^W,
\end{cases}
$$
where $W$ is Self::WIDTH
.
§Worst-case complexity
Constant time and additional memory.
§Examples
See here.
source§fn checked_product_of_first_n_primes(n: u64) -> Option<u16>
fn checked_product_of_first_n_primes(n: u64) -> Option<u16>
Computes the product of the first $n$ primes.
The checked_primorial
function is similar;
it computes the product of all primes less than or equal to $n$.
If the input is too large, the function returns None
.
$$
f(n) = \begin{cases}
\operatorname{Some}(p_n\#) & \text{if} \quad p_n\# < 2^W, \\
\operatorname{None} & \text{if} \quad p_n\# \geq 2^W,
\end{cases}
$$
where $W$ is Self::WIDTH
.
§Worst-case complexity
Constant time and additional memory.
§Examples
See here.
source§impl CheckedPrimorial for u32
impl CheckedPrimorial for u32
source§fn checked_primorial(n: u64) -> Option<u32>
fn checked_primorial(n: u64) -> Option<u32>
Computes the primorial of a number: the product of all primes less than or equal to it.
The
checked_product_of_first_n_primes
function is similar; it computes the primorial of the $n$th prime.
If the input is too large, the function returns None
.
$$
f(n) = \begin{cases}
\operatorname{Some}(n\#) & \text{if} \quad n\# < 2^W, \\
\operatorname{None} & \text{if} \quad n\# \geq 2^W,
\end{cases}
$$
where $W$ is Self::WIDTH
.
§Worst-case complexity
Constant time and additional memory.
§Examples
See here.
source§fn checked_product_of_first_n_primes(n: u64) -> Option<u32>
fn checked_product_of_first_n_primes(n: u64) -> Option<u32>
Computes the product of the first $n$ primes.
The checked_primorial
function is similar;
it computes the product of all primes less than or equal to $n$.
If the input is too large, the function returns None
.
$$
f(n) = \begin{cases}
\operatorname{Some}(p_n\#) & \text{if} \quad p_n\# < 2^W, \\
\operatorname{None} & \text{if} \quad p_n\# \geq 2^W,
\end{cases}
$$
where $W$ is Self::WIDTH
.
§Worst-case complexity
Constant time and additional memory.
§Examples
See here.
source§impl CheckedPrimorial for u64
impl CheckedPrimorial for u64
source§fn checked_primorial(n: u64) -> Option<u64>
fn checked_primorial(n: u64) -> Option<u64>
Computes the primorial of a number: the product of all primes less than or equal to it.
The
checked_product_of_first_n_primes
function is similar; it computes the primorial of the $n$th prime.
If the input is too large, the function returns None
.
$$
f(n) = \begin{cases}
\operatorname{Some}(n\#) & \text{if} \quad n\# < 2^W, \\
\operatorname{None} & \text{if} \quad n\# \geq 2^W,
\end{cases}
$$
where $W$ is Self::WIDTH
.
§Worst-case complexity
Constant time and additional memory.
§Examples
See here.
source§fn checked_product_of_first_n_primes(n: u64) -> Option<u64>
fn checked_product_of_first_n_primes(n: u64) -> Option<u64>
Computes the product of the first $n$ primes.
The checked_primorial
function is similar;
it computes the product of all primes less than or equal to $n$.
If the input is too large, the function returns None
.
$$
f(n) = \begin{cases}
\operatorname{Some}(p_n\#) & \text{if} \quad p_n\# < 2^W, \\
\operatorname{None} & \text{if} \quad p_n\# \geq 2^W,
\end{cases}
$$
where $W$ is Self::WIDTH
.
§Worst-case complexity
Constant time and additional memory.
§Examples
See here.
source§impl CheckedPrimorial for u128
impl CheckedPrimorial for u128
source§fn checked_primorial(n: u64) -> Option<u128>
fn checked_primorial(n: u64) -> Option<u128>
Computes the primorial of a number: the product of all primes less than or equal to it.
The
checked_product_of_first_n_primes
function is similar; it computes the primorial of the $n$th prime.
If the input is too large, the function returns None
.
$$
f(n) = \begin{cases}
\operatorname{Some}(n\#) & \text{if} \quad n\# < 2^W, \\
\operatorname{None} & \text{if} \quad n\# \geq 2^W,
\end{cases}
$$
where $W$ is Self::WIDTH
.
§Worst-case complexity
Constant time and additional memory.
§Examples
See here.
source§fn checked_product_of_first_n_primes(n: u64) -> Option<u128>
fn checked_product_of_first_n_primes(n: u64) -> Option<u128>
Computes the product of the first $n$ primes.
The checked_primorial
function is similar;
it computes the product of all primes less than or equal to $n$.
If the input is too large, the function returns None
.
$$
f(n) = \begin{cases}
\operatorname{Some}(p_n\#) & \text{if} \quad p_n\# < 2^W, \\
\operatorname{None} & \text{if} \quad p_n\# \geq 2^W,
\end{cases}
$$
where $W$ is Self::WIDTH
.
§Worst-case complexity
Constant time and additional memory.
§Examples
See here.
source§impl CheckedPrimorial for usize
impl CheckedPrimorial for usize
source§fn checked_primorial(n: u64) -> Option<usize>
fn checked_primorial(n: u64) -> Option<usize>
Computes the primorial of a usize
: the product of all primes less than or equal to it.
The
checked_product_of_first_n_primes
function is similar; it computes the primorial of the $n$th prime.
If the input is too large, the function returns None
.
$$
f(n) = \begin{cases}
\operatorname{Some}(n\#) & \text{if} \quad n\# < 2^W, \\
\operatorname{None} & \text{if} \quad n\# \geq 2^W,
\end{cases}
$$
where $W$ is usize::WIDTH
.
§Worst-case complexity
Constant time and additional memory.
§Examples
See here.
source§fn checked_product_of_first_n_primes(n: u64) -> Option<usize>
fn checked_product_of_first_n_primes(n: u64) -> Option<usize>
Computes the product of the first $n$ primes.
The checked_primorial
function is similar; it
computes the product of all primes less than or equal to $n$.
If the input is too large, the function returns None
.
$$
f(n) = \begin{cases}
\operatorname{Some}(p_n\#) & \text{if} \quad p_n\# < 2^W, \\
\operatorname{None} & \text{if} \quad p_n\# \geq 2^W,
\end{cases}
$$
where $W$ is usize::WIDTH
.
§Worst-case complexity
Constant time and additional memory.
§Examples
See here.