pub trait Factorial {
// Required method
fn factorial(n: u64) -> Self;
}
Expand description
Computes the factorial of a u64
.
Required Methods§
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 Factorial for u8
impl Factorial for u8
Source§fn factorial(n: u64) -> u8
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
impl Factorial for u16
Source§fn factorial(n: u64) -> u16
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
impl Factorial for u32
Source§fn factorial(n: u64) -> u32
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
impl Factorial for u64
Source§fn factorial(n: u64) -> u64
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
impl Factorial for u128
Source§fn factorial(n: u64) -> u128
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
impl Factorial for usize
Source§fn factorial(n: u64) -> usize
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.