Main Content

Binomial coefficient or all combinations

returns the binomial coefficient, defined as `b`

= nchoosek(`n`

,`k`

)

$${}_{n}C{\text{\hspace{0.17em}}}_{k}=\left(\begin{array}{c}n\\ k\end{array}\right)=\frac{n!}{\left(n-k\right)!\text{\hspace{0.17em}}\text{\hspace{0.17em}}k!}\text{\hspace{0.17em}}.$$

This is the number of combinations of `n`

items
taken `k`

at a time. `n`

and `k`

must be nonnegative integers.

When

`b = nchoosek(n,k)`

is sufficiently large,`nchoosek`

displays a warning that the result might not be exact. In this case, the result is only accurate to 15 digits for double-precision inputs, or 8 digits for single-precision inputs.`C = nchoosek(v,k)`

is only practical for situations where`length(v)`

is less than about`15`

.