Lably
Skip to content

Combination

Selection of items from a set

  • 9 min read
  • 5 chapters
  • 6 labs on Lably

Learn it on Lably

(nk)=n(n−1)⋯(n−k+1)k(k−1)⋯1,

which using factorial notation can be compactly expressed as

(nk)=n!k!(n−k)!

whenever n≥k≥0. This formula can be derived from the fact that each k-combination of a set S of n members has k! permutations so Pkn=Ckn×k! or Ckn=Pkn/k!. The set of all k-combinations of a set S is often denoted by (Sk).

A combination is a selection of n things taken k at a time without repetition. To refer to combinations in which repetition is allowed, the terms k-combination with repetition, k-multiset, or k-selection, are often used. If, in the above example, it were possible to have two of any one kind of fruit there would be 3 more 2-selections: one with two apples, one with two oranges, and one with two pears.

Although the set of three fruits was small enough to write a complete list of combinations, this becomes impractical as the size of the set increases. For example, a poker hand can be described as a 5-combination (k = 5) of cards from a 52 card deck (n = 52). The 5 cards of the hand are all distinct, and the order of cards in the hand does not matter. There are 2,598,960 such combinations, and the chance of drawing any one hand at random is 1 / 2,598,960.

Number of k-combinations

The number of k-combinations from a given set S of n elements is often denoted in elementary combinatorics texts by C(n,k), or by a variation such as Ckn, nCk, nCk, Cn,k or even Cnk. The same number however occurs in many other mathematical contexts, where it is denoted by (nk) (often read as "n choose k"); notably it occurs as a coefficient in the binomial formula, hence its name binomial coefficient. One can define (nk) for all natural numbers k at once by the relation

(1+X)n=∑k≥0(nk)Xk,

from which it is clear that

(n0)=(nn)=1,

and further

(nk)=0

for k>n.

To see that these coefficients count k-combinations from S, one can first consider a collection of n distinct variables Xs labeled by the elements s of S, and expand the product over all elements of S:

∏s∈S(1+Xs);

it has 2n distinct terms corresponding to all the subsets of S, each subset giving the product of the corresponding variables Xs. Now setting all of the Xs equal to the unlabeled variable X, so that the product becomes (1 + X)n, the term for each k-combination from S becomes Xk, so that the coefficient of that power in the result equals the number of such k-combinations.

Binomial coefficients can be computed explicitly in various ways. To get all of them for the expansions up to (1 + X)n, one can use (in addition to the basic cases already given) the recursion relation

(nk)=(n−1k−1)+(n−1k),

for 0 < k < n, which follows from (1 + X)n = (1 + X)n − 1(1 + X); this leads to the construction of Pascal's triangle.

For determining an individual binomial coefficient, it is more practical to use the formula

(nk)=n(n−1)(n−2)⋯(n−k+1)k!.

The numerator gives the number of k-permutations of n, i.e., of sequences of k distinct elements of S, while the denominator gives the number of such k-permutations that give the same k-combination when the order is ignored.

When k exceeds n/2, the above formula contains factors common to the numerator and the denominator, and canceling them out gives the relation

(nk)=(nn−k),

for 0 ≤ k ≤ n. This expresses a symmetry that is evident from the binomial formula, and can also be understood in terms of k-combinations by taking the complement of such a combination, which is an (n − k)-combination.

Finally there is a formula which exhibits this symmetry directly, and has the merit of being easy to remember:

(nk)=n!k!(n−k)!,

where n! denotes the factorial of n. It is obtained from the previous formula by multiplying denominator and numerator by (n − k)!, so it is certainly computationally less efficient than that formula.

The last formula can be understood directly, by considering the n! permutations of all the elements of S. Each such permutation gives a k-combination by selecting its first k elements. There are many duplicate selections: any combined permutation of the first k elements among each other, and of the final (n − k) elements among each other produces the same combination; this explains the division in the formula.

From the above formulas follow relations between adjacent numbers in Pascal's triangle in all three directions:

(nk)={(nk−1)n−k+1kif k>0(n−1k)nn−kif k<n(n−1k−1)nkif n,k>0.

Together with the basic cases (n0)=1=(nn), these allow successive computation of respectively all numbers of combinations from the same set (a row in Pascal's triangle), of k-combinations of sets of growing sizes, and of combinations with a complement of fixed size n − k.

Example of counting combinations

As a specific example, one can compute the number of five-card hands possible from a standard fifty-two card deck as:

(525)=52×51×50×49×485×4×3×2×1=311,875,200120=2,598,960.

Alternatively, one may use the formula in terms of factorials and cancel the factors in the numerator against parts of the factors in the denominator, after which only multiplication of the remaining factors is required: (525)=52!5!47!=52×51×50×49×48×47!5×4×3×2×1×47!=52×51×50×49×485×4×3×2=(26×2)×(17×3)×(10×5)×49×(12×4)5×4×3×2=26×17×10×49×12=2,598,960.

Another alternative computation, equivalent to the first, is based on writing

(nk)=(n−0)1×(n−1)2×(n−2)3×⋯×(n−(k−1))k,

which gives

(525)=521×512×503×494×485=2,598,960.

When evaluated in the following order, 52 ÷ 1 × 51 ÷ 2 × 50 ÷ 3 × 49 ÷ 4 × 48 ÷ 5, this can be computed using only integer arithmetic. The reason is that when each division occurs, the intermediate result that is produced is itself a binomial coefficient, so no remainders ever occur.

Using the symmetric formula in terms of factorials without performing simplifications gives a rather extensive calculation:

(525)=n!k!(n−k)!=52!5!(52−5)!=52!5!47!=80,658,175,170,943,878,571,660,636,856,403,766,975,289,505,440,883,277,824,000,000,000,000120×258,623,241,511,168,180,642,964,355,153,611,979,969,197,632,389,120,000,000,000=2,598,960.

Enumerating k-combinations

One can enumerate all k-combinations of a given set S of n elements in some fixed order, which establishes a bijection from an interval of (nk) integers with the set of those k-combinations. Assuming S is itself ordered, for instance S = { 1, 2, ..., n }, there are two natural possibilities for ordering its k-combinations: by comparing their smallest elements first (as in the illustrations above) or by comparing their largest elements first. The latter option has the advantage that adding a new largest element to S will not change the initial part of the enumeration, but just add the new k-combinations of the larger set after the previous ones. Repeating this process, the enumeration can be extended indefinitely with k-combinations of ever larger sets. If moreover the intervals of the integers are taken to start at 0, then the k-combination at a given place i in the enumeration can be computed easily from i, and the bijection so obtained is known as the combinatorial number system. It is also known as "rank"/"ranking" and "unranking" in computational mathematics.

There are many ways to enumerate k combinations. One way is to track k index numbers of the elements selected, starting with {0 .. k−1} (zero-based) or {1 .. k} (one-based) as the first allowed k-combination. Then, repeatedly move to the next allowed k-combination by incrementing the smallest index number for which this would not create two equal index numbers, at the same time resetting all smaller index numbers to their initial values.

Sign in to keep reading

4 more chapters are free with a Lably account.

More in Discrete mathematics