Trait malachite_base::num::arithmetic::traits::Factorial

source ·
pub trait Factorial {
    // Required method
    fn factorial(n: u64) -> Self;
}
Expand description

Computes the factorial of a u64.

Required Methods§

source

fn factorial(n: u64) -> Self

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

source§

impl Factorial for u8

source§

fn factorial(n: u64) -> u8

Computes the factorial of a number.

If the input is too large, the function panics. For a function that returns None instead, try checked_factorial.

$$ f(n) = n! = 1 \times 2 \times 3 \times \cdots \times n. $$

$n! = O(\sqrt{n}(n/e)^n)$.

§Worst-case complexity

Constant time and additional memory.

§Panics

Panics if the output is too large to be represented.

§Examples

See here.

source§

impl Factorial for u16

source§

fn factorial(n: u64) -> u16

Computes the factorial of a number.

If the input is too large, the function panics. For a function that returns None instead, try checked_factorial.

$$ f(n) = n! = 1 \times 2 \times 3 \times \cdots \times n. $$

$n! = O(\sqrt{n}(n/e)^n)$.

§Worst-case complexity

Constant time and additional memory.

§Panics

Panics if the output is too large to be represented.

§Examples

See here.

source§

impl Factorial for u32

source§

fn factorial(n: u64) -> u32

Computes the factorial of a number.

If the input is too large, the function panics. For a function that returns None instead, try checked_factorial.

$$ f(n) = n! = 1 \times 2 \times 3 \times \cdots \times n. $$

$n! = O(\sqrt{n}(n/e)^n)$.

§Worst-case complexity

Constant time and additional memory.

§Panics

Panics if the output is too large to be represented.

§Examples

See here.

source§

impl Factorial for u64

source§

fn factorial(n: u64) -> u64

Computes the factorial of a number.

If the input is too large, the function panics. For a function that returns None instead, try checked_factorial.

$$ f(n) = n! = 1 \times 2 \times 3 \times \cdots \times n. $$

$n! = O(\sqrt{n}(n/e)^n)$.

§Worst-case complexity

Constant time and additional memory.

§Panics

Panics if the output is too large to be represented.

§Examples

See here.

source§

impl Factorial for u128

source§

fn factorial(n: u64) -> u128

Computes the factorial of a number.

If the input is too large, the function panics. For a function that returns None instead, try checked_factorial.

$$ f(n) = n! = 1 \times 2 \times 3 \times \cdots \times n. $$

$n! = O(\sqrt{n}(n/e)^n)$.

§Worst-case complexity

Constant time and additional memory.

§Panics

Panics if the output is too large to be represented.

§Examples

See here.

source§

impl Factorial for usize

source§

fn factorial(n: u64) -> usize

Computes the factorial of a number.

If the input is too large, the function panics. For a function that returns None instead, try checked_factorial.

$$ f(n) = n! = 1 \times 2 \times 3 \times \cdots \times n. $$

$n! = O(\sqrt{n}(n/e)^n)$.

§Worst-case complexity

Constant time and additional memory.

§Panics

Panics if the output is too large to be represented.

§Examples

See here.

Implementors§