pub trait BinomialCoefficient<T = Self> {
// Required method
fn binomial_coefficient(n: T, k: T) -> Self;
}
Required Methods§
fn binomial_coefficient(n: T, k: T) -> 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 BinomialCoefficient for i8
impl BinomialCoefficient for i8
Source§fn binomial_coefficient(n: i8, k: i8) -> i8
fn binomial_coefficient(n: i8, k: i8) -> i8
Computes the binomial coefficient of two numbers. If the inputs are too large, the function panics.
The second argument must be non-negative, but the first may be negative. If it is, the identity $\binom{-n}{k} = (-1)^k \binom{n+k-1}{k}$ is used.
$$ f(n, k) = \begin{cases} \binom{n}{k} & \text{if} \quad n \geq 0, \\ (-1)^k \binom{-n+k-1}{k} & \text{if} \quad n < 0. \end{cases} $$
§Worst-case complexity
$T(k) = O(k)$
$M(k) = O(1)$
where $T$ is time, $M$ is additional memory, and $k$ is k.abs()
.
§Panics
Panics if the result is not representable by this type, or if $k$ is negative.
§Examples
See here.
Source§impl BinomialCoefficient for i16
impl BinomialCoefficient for i16
Source§fn binomial_coefficient(n: i16, k: i16) -> i16
fn binomial_coefficient(n: i16, k: i16) -> i16
Computes the binomial coefficient of two numbers. If the inputs are too large, the function panics.
The second argument must be non-negative, but the first may be negative. If it is, the identity $\binom{-n}{k} = (-1)^k \binom{n+k-1}{k}$ is used.
$$ f(n, k) = \begin{cases} \binom{n}{k} & \text{if} \quad n \geq 0, \\ (-1)^k \binom{-n+k-1}{k} & \text{if} \quad n < 0. \end{cases} $$
§Worst-case complexity
$T(k) = O(k)$
$M(k) = O(1)$
where $T$ is time, $M$ is additional memory, and $k$ is k.abs()
.
§Panics
Panics if the result is not representable by this type, or if $k$ is negative.
§Examples
See here.
Source§impl BinomialCoefficient for i32
impl BinomialCoefficient for i32
Source§fn binomial_coefficient(n: i32, k: i32) -> i32
fn binomial_coefficient(n: i32, k: i32) -> i32
Computes the binomial coefficient of two numbers. If the inputs are too large, the function panics.
The second argument must be non-negative, but the first may be negative. If it is, the identity $\binom{-n}{k} = (-1)^k \binom{n+k-1}{k}$ is used.
$$ f(n, k) = \begin{cases} \binom{n}{k} & \text{if} \quad n \geq 0, \\ (-1)^k \binom{-n+k-1}{k} & \text{if} \quad n < 0. \end{cases} $$
§Worst-case complexity
$T(k) = O(k)$
$M(k) = O(1)$
where $T$ is time, $M$ is additional memory, and $k$ is k.abs()
.
§Panics
Panics if the result is not representable by this type, or if $k$ is negative.
§Examples
See here.
Source§impl BinomialCoefficient for i64
impl BinomialCoefficient for i64
Source§fn binomial_coefficient(n: i64, k: i64) -> i64
fn binomial_coefficient(n: i64, k: i64) -> i64
Computes the binomial coefficient of two numbers. If the inputs are too large, the function panics.
The second argument must be non-negative, but the first may be negative. If it is, the identity $\binom{-n}{k} = (-1)^k \binom{n+k-1}{k}$ is used.
$$ f(n, k) = \begin{cases} \binom{n}{k} & \text{if} \quad n \geq 0, \\ (-1)^k \binom{-n+k-1}{k} & \text{if} \quad n < 0. \end{cases} $$
§Worst-case complexity
$T(k) = O(k)$
$M(k) = O(1)$
where $T$ is time, $M$ is additional memory, and $k$ is k.abs()
.
§Panics
Panics if the result is not representable by this type, or if $k$ is negative.
§Examples
See here.
Source§impl BinomialCoefficient for i128
impl BinomialCoefficient for i128
Source§fn binomial_coefficient(n: i128, k: i128) -> i128
fn binomial_coefficient(n: i128, k: i128) -> i128
Computes the binomial coefficient of two numbers. If the inputs are too large, the function panics.
The second argument must be non-negative, but the first may be negative. If it is, the identity $\binom{-n}{k} = (-1)^k \binom{n+k-1}{k}$ is used.
$$ f(n, k) = \begin{cases} \binom{n}{k} & \text{if} \quad n \geq 0, \\ (-1)^k \binom{-n+k-1}{k} & \text{if} \quad n < 0. \end{cases} $$
§Worst-case complexity
$T(k) = O(k)$
$M(k) = O(1)$
where $T$ is time, $M$ is additional memory, and $k$ is k.abs()
.
§Panics
Panics if the result is not representable by this type, or if $k$ is negative.
§Examples
See here.
Source§impl BinomialCoefficient for isize
impl BinomialCoefficient for isize
Source§fn binomial_coefficient(n: isize, k: isize) -> isize
fn binomial_coefficient(n: isize, k: isize) -> isize
Computes the binomial coefficient of two numbers. If the inputs are too large, the function panics.
The second argument must be non-negative, but the first may be negative. If it is, the identity $\binom{-n}{k} = (-1)^k \binom{n+k-1}{k}$ is used.
$$ f(n, k) = \begin{cases} \binom{n}{k} & \text{if} \quad n \geq 0, \\ (-1)^k \binom{-n+k-1}{k} & \text{if} \quad n < 0. \end{cases} $$
§Worst-case complexity
$T(k) = O(k)$
$M(k) = O(1)$
where $T$ is time, $M$ is additional memory, and $k$ is k.abs()
.
§Panics
Panics if the result is not representable by this type, or if $k$ is negative.
§Examples
See here.
Source§impl BinomialCoefficient for u8
impl BinomialCoefficient for u8
Source§fn binomial_coefficient(n: u8, k: u8) -> u8
fn binomial_coefficient(n: u8, k: u8) -> u8
Computes the binomial coefficient of two numbers. If the inputs are too large, the function panics.
The second argument must be non-negative, but the first may be negative. If it is, the identity $\binom{-n}{k} = (-1)^k \binom{n+k-1}{k}$ is used.
$$ f(n, k) = \begin{cases} \binom{n}{k} & \text{if} \quad n \geq 0, \\ (-1)^k \binom{-n+k-1}{k} & \text{if} \quad n < 0. \end{cases} $$
§Worst-case complexity
$T(k) = O(k)$
$M(k) = O(1)$
where $T$ is time, $M$ is additional memory, and $k$ is k.abs()
.
§Panics
Panics if the result is not representable by this type, or if $k$ is negative.
§Examples
See here.
Source§impl BinomialCoefficient for u16
impl BinomialCoefficient for u16
Source§fn binomial_coefficient(n: u16, k: u16) -> u16
fn binomial_coefficient(n: u16, k: u16) -> u16
Computes the binomial coefficient of two numbers. If the inputs are too large, the function panics.
The second argument must be non-negative, but the first may be negative. If it is, the identity $\binom{-n}{k} = (-1)^k \binom{n+k-1}{k}$ is used.
$$ f(n, k) = \begin{cases} \binom{n}{k} & \text{if} \quad n \geq 0, \\ (-1)^k \binom{-n+k-1}{k} & \text{if} \quad n < 0. \end{cases} $$
§Worst-case complexity
$T(k) = O(k)$
$M(k) = O(1)$
where $T$ is time, $M$ is additional memory, and $k$ is k.abs()
.
§Panics
Panics if the result is not representable by this type, or if $k$ is negative.
§Examples
See here.
Source§impl BinomialCoefficient for u32
impl BinomialCoefficient for u32
Source§fn binomial_coefficient(n: u32, k: u32) -> u32
fn binomial_coefficient(n: u32, k: u32) -> u32
Computes the binomial coefficient of two numbers. If the inputs are too large, the function panics.
The second argument must be non-negative, but the first may be negative. If it is, the identity $\binom{-n}{k} = (-1)^k \binom{n+k-1}{k}$ is used.
$$ f(n, k) = \begin{cases} \binom{n}{k} & \text{if} \quad n \geq 0, \\ (-1)^k \binom{-n+k-1}{k} & \text{if} \quad n < 0. \end{cases} $$
§Worst-case complexity
$T(k) = O(k)$
$M(k) = O(1)$
where $T$ is time, $M$ is additional memory, and $k$ is k.abs()
.
§Panics
Panics if the result is not representable by this type, or if $k$ is negative.
§Examples
See here.
Source§impl BinomialCoefficient for u64
impl BinomialCoefficient for u64
Source§fn binomial_coefficient(n: u64, k: u64) -> u64
fn binomial_coefficient(n: u64, k: u64) -> u64
Computes the binomial coefficient of two numbers. If the inputs are too large, the function panics.
The second argument must be non-negative, but the first may be negative. If it is, the identity $\binom{-n}{k} = (-1)^k \binom{n+k-1}{k}$ is used.
$$ f(n, k) = \begin{cases} \binom{n}{k} & \text{if} \quad n \geq 0, \\ (-1)^k \binom{-n+k-1}{k} & \text{if} \quad n < 0. \end{cases} $$
§Worst-case complexity
$T(k) = O(k)$
$M(k) = O(1)$
where $T$ is time, $M$ is additional memory, and $k$ is k.abs()
.
§Panics
Panics if the result is not representable by this type, or if $k$ is negative.
§Examples
See here.
Source§impl BinomialCoefficient for u128
impl BinomialCoefficient for u128
Source§fn binomial_coefficient(n: u128, k: u128) -> u128
fn binomial_coefficient(n: u128, k: u128) -> u128
Computes the binomial coefficient of two numbers. If the inputs are too large, the function panics.
The second argument must be non-negative, but the first may be negative. If it is, the identity $\binom{-n}{k} = (-1)^k \binom{n+k-1}{k}$ is used.
$$ f(n, k) = \begin{cases} \binom{n}{k} & \text{if} \quad n \geq 0, \\ (-1)^k \binom{-n+k-1}{k} & \text{if} \quad n < 0. \end{cases} $$
§Worst-case complexity
$T(k) = O(k)$
$M(k) = O(1)$
where $T$ is time, $M$ is additional memory, and $k$ is k.abs()
.
§Panics
Panics if the result is not representable by this type, or if $k$ is negative.
§Examples
See here.
Source§impl BinomialCoefficient for usize
impl BinomialCoefficient for usize
Source§fn binomial_coefficient(n: usize, k: usize) -> usize
fn binomial_coefficient(n: usize, k: usize) -> usize
Computes the binomial coefficient of two numbers. If the inputs are too large, the function panics.
The second argument must be non-negative, but the first may be negative. If it is, the identity $\binom{-n}{k} = (-1)^k \binom{n+k-1}{k}$ is used.
$$ f(n, k) = \begin{cases} \binom{n}{k} & \text{if} \quad n \geq 0, \\ (-1)^k \binom{-n+k-1}{k} & \text{if} \quad n < 0. \end{cases} $$
§Worst-case complexity
$T(k) = O(k)$
$M(k) = O(1)$
where $T$ is time, $M$ is additional memory, and $k$ is k.abs()
.
§Panics
Panics if the result is not representable by this type, or if $k$ is negative.
§Examples
See here.