pub trait Primorial {
    // Required methods
    fn primorial(n: u64) -> Self;
    fn product_of_first_n_primes(n: u64) -> Self;
}

Required Methods§

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

source§

impl Primorial for u8

source§

fn primorial(n: u64) -> u8

Computes the primorial of a number: the product of all primes less than or equal to it.

The 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 panics. For a function that returns None instead, try checked_primorial.

$$ f(n) = n\# = \prod_{p \leq n \atop p \ \text {prime}} p. $$

$n\# = O(e^{(1+o(1))n})$.

§Worst-case complexity

Constant time and additional memory.

§Panics

Panics if the output is too large to be represented.

§Examples

See here.

source§

fn product_of_first_n_primes(n: u64) -> u8

Computes the product of the first $n$ primes.

The 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 panics. For a function that returns None instead, try checked_product_of_first_n_primes.

$$ f(n) = p_n\# = \prod_{k=1}^n p_n, $$ where $p_n$ is the $n$th prime number.

$p_n\# = O\left ( \left ( \frac{1}{e}k\log k\left ( \frac{\log k}{e^2}k \right )^{1/\log k} \right )^k \omega(1)\right )$.

This asymptotic approximation is due to Bart Michels.

§Worst-case complexity

Constant time and additional memory.

§Panics

Panics if the output is too large to be represented.

§Examples

See here.

source§

impl Primorial for u16

source§

fn primorial(n: u64) -> u16

Computes the primorial of a number: the product of all primes less than or equal to it.

The 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 panics. For a function that returns None instead, try checked_primorial.

$$ f(n) = n\# = \prod_{p \leq n \atop p \ \text {prime}} p. $$

$n\# = O(e^{(1+o(1))n})$.

§Worst-case complexity

Constant time and additional memory.

§Panics

Panics if the output is too large to be represented.

§Examples

See here.

source§

fn product_of_first_n_primes(n: u64) -> u16

Computes the product of the first $n$ primes.

The 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 panics. For a function that returns None instead, try checked_product_of_first_n_primes.

$$ f(n) = p_n\# = \prod_{k=1}^n p_n, $$ where $p_n$ is the $n$th prime number.

$p_n\# = O\left ( \left ( \frac{1}{e}k\log k\left ( \frac{\log k}{e^2}k \right )^{1/\log k} \right )^k \omega(1)\right )$.

This asymptotic approximation is due to Bart Michels.

§Worst-case complexity

Constant time and additional memory.

§Panics

Panics if the output is too large to be represented.

§Examples

See here.

source§

impl Primorial for u32

source§

fn primorial(n: u64) -> u32

Computes the primorial of a number: the product of all primes less than or equal to it.

The 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 panics. For a function that returns None instead, try checked_primorial.

$$ f(n) = n\# = \prod_{p \leq n \atop p \ \text {prime}} p. $$

$n\# = O(e^{(1+o(1))n})$.

§Worst-case complexity

Constant time and additional memory.

§Panics

Panics if the output is too large to be represented.

§Examples

See here.

source§

fn product_of_first_n_primes(n: u64) -> u32

Computes the product of the first $n$ primes.

The 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 panics. For a function that returns None instead, try checked_product_of_first_n_primes.

$$ f(n) = p_n\# = \prod_{k=1}^n p_n, $$ where $p_n$ is the $n$th prime number.

$p_n\# = O\left ( \left ( \frac{1}{e}k\log k\left ( \frac{\log k}{e^2}k \right )^{1/\log k} \right )^k \omega(1)\right )$.

This asymptotic approximation is due to Bart Michels.

§Worst-case complexity

Constant time and additional memory.

§Panics

Panics if the output is too large to be represented.

§Examples

See here.

source§

impl Primorial for u64

source§

fn primorial(n: u64) -> u64

Computes the primorial of a number: the product of all primes less than or equal to it.

The 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 panics. For a function that returns None instead, try checked_primorial.

$$ f(n) = n\# = \prod_{p \leq n \atop p \ \text {prime}} p. $$

$n\# = O(e^{(1+o(1))n})$.

§Worst-case complexity

Constant time and additional memory.

§Panics

Panics if the output is too large to be represented.

§Examples

See here.

source§

fn product_of_first_n_primes(n: u64) -> u64

Computes the product of the first $n$ primes.

The 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 panics. For a function that returns None instead, try checked_product_of_first_n_primes.

$$ f(n) = p_n\# = \prod_{k=1}^n p_n, $$ where $p_n$ is the $n$th prime number.

$p_n\# = O\left ( \left ( \frac{1}{e}k\log k\left ( \frac{\log k}{e^2}k \right )^{1/\log k} \right )^k \omega(1)\right )$.

This asymptotic approximation is due to Bart Michels.

§Worst-case complexity

Constant time and additional memory.

§Panics

Panics if the output is too large to be represented.

§Examples

See here.

source§

impl Primorial for u128

source§

fn primorial(n: u64) -> u128

Computes the primorial of a number: the product of all primes less than or equal to it.

The 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 panics. For a function that returns None instead, try checked_primorial.

$$ f(n) = n\# = \prod_{p \leq n \atop p \ \text {prime}} p. $$

$n\# = O(e^{(1+o(1))n})$.

§Worst-case complexity

Constant time and additional memory.

§Panics

Panics if the output is too large to be represented.

§Examples

See here.

source§

fn product_of_first_n_primes(n: u64) -> u128

Computes the product of the first $n$ primes.

The 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 panics. For a function that returns None instead, try checked_product_of_first_n_primes.

$$ f(n) = p_n\# = \prod_{k=1}^n p_n, $$ where $p_n$ is the $n$th prime number.

$p_n\# = O\left ( \left ( \frac{1}{e}k\log k\left ( \frac{\log k}{e^2}k \right )^{1/\log k} \right )^k \omega(1)\right )$.

This asymptotic approximation is due to Bart Michels.

§Worst-case complexity

Constant time and additional memory.

§Panics

Panics if the output is too large to be represented.

§Examples

See here.

source§

impl Primorial for usize

source§

fn primorial(n: u64) -> usize

Computes the primorial of a number: the product of all primes less than or equal to it.

The 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 panics. For a function that returns None instead, try checked_primorial.

$$ f(n) = n\# = \prod_{p \leq n \atop p \ \text {prime}} p. $$

$n\# = O(e^{(1+o(1))n})$.

§Worst-case complexity

Constant time and additional memory.

§Panics

Panics if the output is too large to be represented.

§Examples

See here.

source§

fn product_of_first_n_primes(n: u64) -> usize

Computes the product of the first $n$ primes.

The 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 panics. For a function that returns None instead, try checked_product_of_first_n_primes.

$$ f(n) = p_n\# = \prod_{k=1}^n p_n, $$ where $p_n$ is the $n$th prime number.

$p_n\# = O\left ( \left ( \frac{1}{e}k\log k\left ( \frac{\log k}{e^2}k \right )^{1/\log k} \right )^k \omega(1)\right )$.

This asymptotic approximation is due to Bart Michels.

§Worst-case complexity

Constant time and additional memory.

§Panics

Panics if the output is too large to be represented.

§Examples

See here.

Implementors§