pub trait BinomialCoefficient<T = Self> {
    // Required method
    fn binomial_coefficient(n: T, k: T) -> Self;
}

Required Methods§

source

fn binomial_coefficient(n: T, k: T) -> Self

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

source§

impl BinomialCoefficient for i8

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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.

Implementors§