DADiSP Worksheet Functions > Function Categories > Statistics and Calculus > NCHOOSEK
Computes the binomial coefficient or returns all the unordered combinations of the elements of the input series.
NCHOOSEK(n, k)
n |
- |
A scalar or series |
k |
- |
A scalar or series |
A scalar or series, the number of combinations of n items taken in unordered groups of k, or if n is a series and k a positive integer, the actual unordered combinations of the series elements where each row represents a group of k elements.
nchoosek(5, 3)
returns 10.
c = nchoosek(1..5, 3)
c == {{1, 2, 3},
{1, 2, 4},
{1, 2, 5},
{1, 3, 4},
{1, 3, 5},
{1, 4, 5},
{2, 3, 4},
{2, 3, 5},
{2, 4, 5},
{3, 4, 5}}
nchoosek(5.3, 3)
returns 12.5345.
c = nchoosek(3..5, 1..3)
c == {3, 6, 10} == {nchoosek(3, 1), nchoosek(4, 2), nchoosek(5, 3)}
To return the actual combinations, n must be a series and k must be an integer where
For scalar inputs, n and k can be any value.
For integer values where 0 <= k <= n:
See BINCOEFF to return the generalized binomial coefficient for any scalar or series inputs.