CalcCombination
CalcCombination
CalcCombination[ n, k ] returns the number of ways to choose k items from a set of n items.
Usages
CalcCombination[ n, k ]
CalcCombination[ n, k ] returns , the number of ways to choose k items from a set of n items, where the order does not matter. n and k must be non-negative integers with k ≤ n.
| Example | in | out |
|---|---|---|
Choose 2 items out of 5. |
CalcCombination[ 5, 2 ] |
10 |
Choose 5 cards out of 52. |
CalcCombination[ 52, 5 ] |
2598960 |
| There is one way to choose nothing. | CalcCombination[ 6, 0 ] |
1 |
| There is one way to choose everything. | CalcCombination[ 6, 6 ] |
1 |
| Script variables. | n := 10 |
r = 120 |
Details
- Large numbers: the smaller of
kandn-kmay be at most100.CalcCombination[ 300, 250 ]is calculated, because300-250 = 50, butCalcCombination[ 300, 150 ]is left unevaluated. - Lists are not supported:
CalcCombination[ {5,6}, 2 ]is left unevaluated. UseMapto apply it to each element.
| Invalid input | Result |
|---|---|
CalcCombination[ 6, 7 ] |
Left unevaluated: k is larger than n. |
CalcCombination[ -6, 2 ] |
Left unevaluated: n and k must not be negative. |