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>
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.
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.