Click or drag to resize

CombinatoricBinomialCoefficient Method

Returns the binomial coefficient of the supplied values.

Namespace:  Kaos.Combinatorics
Assembly:  KaosCombinatorics (in KaosCombinatorics.dll) Version: 6.0.0.0
Syntax
C#
public static long BinomialCoefficient(
	int n,
	int k
)

Parameters

n
Type: SystemInt32
Number of choices.
k
Type: SystemInt32
Number of picks.

Return Value

Type: Int64
The binomial coefficient of n choose k.
Exceptions
ExceptionCondition
OverflowExceptionWhen the numbers are just too big.
Remarks
The result is equal to row n, column k of Pascal's triangle with counting starting at 0.
Examples

The number of rows in a Combination table of k picks from n choices is:

Combinatoric.BinomialCoefficient (n, k)

The number of rows in a Multicombination table of k picks from n choices is:

Combinatoric.BinomialCoefficient (k+n-1, k)

An exception to the above formulas is the special case where the number of elements is 0. While mathematics treats this result as 1 row containing the empty product, this library returns 0 rows.

See Also