Taking k elements out of a set of n elements gives a k-combination.
For the set of the numbers from 1 to 5, the combinations are these:
- 1-combinations (1 element at a time): (1), (2), (3), (4), (5)
- 2-combinations (2 elements at a time): (1, 2), (1, 3), (1, 4), (1, 5), (2, 3), (2, 4), (2, 5), (3, 4), (3, 5), (4, 5)
- 3-combinations (3 elements at a time): (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)
- 4-combinations (4 elements at a time): (1, 2, 3, 4), (1, 2, 3, 5), (1, 2, 4, 5), (1, 3, 4, 5), (2, 3, 4, 5)
- 5-combination (all elements at once): (1, 2, 3, 4, 5)
- 0-combination (no element): ()
The number of k-combinations of a set of n elements comes from this formula:
(kn)=k(k−1)⋯1n(n−1)⋯(n−k+1)
The list above gives (05)=1, (15)=5, (25)=10, (35)=10, (45)=5, (55)=1.
Given several (n,k) pairs, compute (kn) for each one.