nchoosek
Binomial coefficient or combinations.
📝Syntax
c = nchoosek(n, k)
C = nchoosek(v, k)
📥Input Arguments
Parameter Description
n nonnegative integer scalar: number of available choices.
v vector containing the available elements.
k nonnegative integer scalar: number of selected elements.
📤Output Arguments
Parameter Description
c binomial coefficient when the first input is a scalar.
C matrix whose rows contain the k-element combinations of v.
📄Description

nchoosek(n, k) returns the binomial coefficient for nonnegative integer scalar n.

nchoosek(v, k) returns a matrix containing all k-element combinations of the elements of vector v.

💡Examples
Compute a binomial coefficient and all two-element combinations of a vector.
b = nchoosek(5, 2)
C = nchoosek([10 20 30 40], 2)
🔗See Also
factorialprod
Used Functions
factorial
🕔Version History
Version Description
2.0.0 initial version
Edit this page on GitHub