# Probability/Combinatorics

## What is combinatorics?

Combinatorics involves the counting and enumeration of elements of sets and similar structures such as sequences and multisets. We have discussed set theory in the chapter about set theory, and we will briefly discuss what is sequence and multiset.

Roughly speaking, a sequence is like a set, but ordering of elements matters, and a multiset is also like a set, but repetition of an element is allowed.

Sequence corresponds to the discussion about ordered selection without replacement, while multiset corresponds to the discussion about unordered selection with replacement.

## Fundamental counting principles

Theorem.

Venn diagram illustrating inclusion-exclusion principle when ${\displaystyle n=3}$ (area of each (intersection of) set can be interpreted as its cardinality).

(Inclusion-exclusion principle) For each finite set ${\displaystyle S_{1},S_{2},\dotsc ,S_{n}}$,

{\displaystyle {\begin{aligned}\#(S_{1}\cup \dotsb \cup S_{n})&=\#(S_{1})+\dotsb +\#(S_{n})\\&\;-{\big (}\#(S_{1}\cap S_{2})+\#(S_{1}\cap S_{3})+\dotsb +\#(S_{n-1}\cap S_{n}){\big )}\\&\;+{\big (}\#(S_{1}\cap S_{2}\cap S_{3})+\#(S_{1}\cap S_{2}\cap S_{4})+\dotsb +\#(S_{n-2}\cap S_{n-1}\cap S_{n}){\big )}\\&\;-\dotsb \\&\;+(-1)^{n+1}\#(S_{1}\cap \dotsb \cap S_{n}).\end{aligned}}}

Proof. Idea:

• To find the cardinality of the union of ${\displaystyle n}$ sets:
1. Include the cardinalities of each of the ${\displaystyle n}$ sets.
2. Exclude the cardinalities of the pairwise intersections (if needed).
3. Include the cardinalities of the triple-wise intersections (if needed).
4. Exclude the cardinalities of the quadruple-wise intersections (if needed).
5. Include the cardinalities of the quintuple-wise intersections (if needed).
6. Continue, until the cardinality of the ${\displaystyle n}$-tuple-wise intersection is included (if ${\displaystyle n}$ is odd) or excluded (if ${\displaystyle n}$ is even).

${\displaystyle \Box }$

Remark.

• The formula can be written more compactly as
${\displaystyle \sum _{j=1}^{n}(-1)^{j+1}\underbrace {\sum _{i_{1}
• The definition of ${\displaystyle {\binom {n}{j}}}$ will be discussed later in this chapter.
• The formula is usually used for the case ${\displaystyle n=2}$ and ${\displaystyle n=3}$.
• When ${\displaystyle n=2}$, the formula becomes ${\displaystyle \#(S_{1}\cup S_{2})=\#(S_{1})+\#(S_{2})-\#(S_{1}\cap S_{2})}$.
• When ${\displaystyle n=3}$, the formula becomes ${\displaystyle \#(S_{1}\cup S_{2}\cup S_{3})=\#(S_{1})+\#(S_{2})+\#(S_{3})-\#(S_{1}\cap S_{2})-\#(S_{1}\cap S_{3})-\#(S_{2}\cap S_{3})+\#(S_{1}\cap S_{2}\cap S_{3})}$.
• The name 'inclusion-exclusion principle' comes from the idea that the principle is based on over-generous inclusion, and then followed by compensating exclusion.

Example. Among 140 people, 110 of them speak at least one of English, French and German. Given that

• 90, 30, 42 of them speak English, French, German respectively;
• 23 speak English and French;
• 25 speak English and German;
• 16 speak French and German.

Then, the no. of people that speak English, French and German is ${\displaystyle 110-90-30-42+23+25+16=12}$.

Proof. Let ${\displaystyle E}$, ${\displaystyle F}$, ${\displaystyle G}$ be the set containing people speaking English, French and German respectively. Then, by inclusion-exclusion principle,

${\displaystyle \#(E\cup F\cup G)=\#(E)+\#(F)\#(G)-\#(E\cap F)-\#(F\cap G)-\#(E\cap G)+\#(E\cap F\cap G)\Rightarrow 110=90+30+42-23-29-16+\#(E\cap F\cap G),}$
and the result follows.

Venn diagram

*----------------*
|90-13-12-11=54  | <---- E
|      *---------*--------------*
|      |25-12=13 |42-13-12-4=13 | <--- G
*------*---------*--------------*-----*
|      |   12    |16-12=4       |     |
|      *---------*--------------*     | <--- F
|  23-12=11      |  30-11-12-4=3      |
*----------------*--------------------*
140-110=30


${\displaystyle \Box }$

Exercise.

1 Calculate the no. of people that speak (a) English only; (b) French only; (c) German only.

 (a) 90; (b) 30; (c) 42 (a) 54; (b) 13; (c) 3 (a) 54; (b) 11; (c) 3 (a) 54; (b) 3; (c) 11 None of the above.

2 Suppose ${\displaystyle k}$ people among the 140 people now learn to speak English. Calculate ${\displaystyle k}$ such that 123 of them speak at least one of English, French and German, and 20 people speak English, French and German now.

 20 21 22 23 None of the above.

3 Continue from previous question. Calculate the no. of people who speak English and French now.

 23 31 36 44 None of the above.

Theorem. (Multiplication counting principle) If trial ${\displaystyle 1,\dotsc ,k}$ has ${\displaystyle n_{1},\dots ,n_{k}}$ possible outcomes respectively, then the ${\displaystyle k}$ trials have ${\displaystyle n_{1}\times \dotsb \times n_{k}}$ possible outcomes.

Proof. First, consider the case for ${\displaystyle k=2}$: we can enumerate each possible outcomes using ordered pair, as follows:

${\displaystyle {\begin{array}{ccccc}{\text{trial 1}}\backslash {\text{trial 2}}&{\text{1st outcome}}&{\text{2nd outcome}}&\dotsb &n_{2}{\text{th outcome}}\\\hline {\text{1st outcome}}&(1,1)&(1,2)&\dotsb &(1,n_{2})\\{\text{2nd outcome}}&(2,1)&(2,2)&\dotsb &(2,n_{2})\\\vdots &\vdots &\vdots &\vdots &\vdots \\n_{1}{\text{th outcome}}&(n_{1},1)&(n_{1},2)&\dotsb &(n_{1},n_{2})\\\end{array}}}$
Then, we can count that there are ${\displaystyle n_{1}n_{2}}$ possible outcomes (by considering the rows (or columns) one by one).

After establishing the case for ${\displaystyle k=2}$, we can establish the case for positive integer ${\displaystyle k\geq 3}$ inductively, e.g.:

${\displaystyle {\begin{array}{ccccc}{\text{trial 1 }}\&{\text{ trial 2}}\backslash {\text{trial 3}}&{\text{1st outcome}}&{\text{2nd outcome}}&\dotsb &n_{3}{\text{th outcome}}\\\hline {\text{1st outcome}}&(1,1,1)&(1,1,2)&\dotsb &(1,1,n_{3})\\{\text{2nd outcome}}&(1,2,1)&(1,2,2)&\dotsb &(1,2,n_{3})\\\vdots &\vdots &\vdots &\vdots &\vdots \\n_{1}n_{2}{\text{th outcome}}&(n_{1},n_{2},1)&(n_{1},n_{2},2)&\dotsb &(n_{1},n_{2},n_{3})\\\end{array}}}$
then we can count that there are ${\displaystyle n_{1}n_{2}n_{3}}$ outcomes (by considering the rows (or columns) one by one), and we can prove the remaining cases inductively.

${\displaystyle \Box }$

Remark.

• It is also known as rule of product.

Example.

Figure 3. In set theory, this is called the Cartesian product
of two sets, with cardinality, ${\displaystyle {\mathcal {N}}=3\times 2}$]]

The tree diagram of Figure 3 illustrates this for ${\displaystyle k=2}$, ${\displaystyle n_{1}=3}$, and ${\displaystyle n_{2}=2}$. The number of possible outcomes is ${\displaystyle {\mathcal {N}}=n_{1}\times n_{2}=6.}$

Exercise.

1 Determine the number of possible outcomes if ${\displaystyle n_{1}=2}$ and ${\displaystyle n_{2}=3}$ instead.

 1 2 3 6 12

2 Suppose ${\displaystyle k=3}$ now. Given that the number of possible outcomes is still 6 without changing other conditions given in the example, calculate ${\displaystyle n_{3}}$.

 1 2 3 6 12

Remark.

• this might be visualized by imagining a flip of three-sided die (with three outcomes, e.g. 1,2,3), followed by a flip of a two-sided coin (with two outcomes, e.g. A,B).

### Counting the number of elements in a power set

Example. (Number of elements in a power set) The number of elements in a power set of set ${\displaystyle S}$ with ${\displaystyle n}$ elements is ${\displaystyle 2^{n}}$.

Proof. Consider the ${\displaystyle n}$ elements in ${\displaystyle S}$ one by one. For each of them, we can either include or do not include it in a subset of ${\displaystyle S}$. Then, there are ${\displaystyle n}$ steps involved to construct a subset of ${\displaystyle S}$, and each step has two outcomes. It follows from the multiplication counting principle that the ${\displaystyle n}$ steps have ${\displaystyle \underbrace {2\times 2\times \dotsb \times 2} _{n{\text{ times}}}=2^{n}}$ outcomes. That is, there are ${\displaystyle 2^{n}}$ possible (distinct) subsets of ${\displaystyle S}$. Since power set contains all subsets of ${\displaystyle S}$ by definition, it follows that the power set has ${\displaystyle 2^{n}}$ elements.

${\displaystyle \Box }$

Exercise.

Determine the number of elements in ${\displaystyle {\mathcal {P}}(\varnothing )}$ (i.e. power set of empty set).

 0 1 2 4 It is undefined.

Remark.

• ${\displaystyle n}$ is arbitrary nonnegative integer

### The counting principle misused

Figure 4. The counting principle is not useful when the number of choices at each step is not unique.
Figure 5. The counting principle only applies if the outcomes are defined such that ${\displaystyle HT\neq TH}$ (i.e. order matters).

Figures 4 and 5 illustrate the fact that the counting principle is not always useful. Figure 4 calculates the ways the three integers can be added to five, if the integers are restricted to the set ${\displaystyle \{1,2,3\}}$. Since these three integers are choices (decisions), it is convenient to label the choice indices with capital letters: ${\displaystyle T_{A},T_{B},T_{C}.}$

E.g., ${\displaystyle T_{B}=3}$ means the second choice is the integer 3.

We cannot apply the counting principle to figure 4 because ${\displaystyle n_{B}}$ depends on ${\displaystyle T_{A}.}$ In our case, ${\displaystyle T_{A}=1\Rightarrow n_{B}=3,}$ and ${\displaystyle T_{A}=2\Rightarrow n_{B}=2,}$ and ${\displaystyle T_{A}=3\Rightarrow n_{B}=1.}$ This leads us to an important caveat about using the counting principle:

• the counting principle cannot be used if the number of outcomes at each step cannot be uniquely defined

Figure 5 exams two flips of a coin. It calculates the correct number of outcomes to be, ${\displaystyle {\mathcal {N}}=2\times 2}$${\displaystyle =4,}$ but only if we carefully define the outcome. The counting principle is valid only if heads followed by a tails (HT) is a different outcome than tails followed by heads (TH). In other words:

• when counting outcomes it is important to understand the role that order (enumeration) plays in defining outcomes

But, if we instead are counting the outcomes in a fashion such that HT and TH are considered to be the same, then a formula such as ${\displaystyle {\mathcal {N}}=n_{A}\times n_{B}}$ cannot be used:

• the counting principle does not hold if two different decision paths lead to the same final outcome (in the theorem, we say 'trial ${\displaystyle 1,\dotsc ,k}$, which implicitly assumes that the order matters in the outcomes for the ${\displaystyle k}$ trials)

Example. Suppose we throw two six-faced dice, with colors red and blue respectively. The number of possible distinct pairs of number facing up is ${\displaystyle 6\cdot 6=36}$.

Proof. Since the dice are distinguishable, we can use multiplication principle of counting. To be more precise, we can let the possible numbers facing up of red dice to be the possible outcomes in 'trial 1', and that of blue dice to be the possible outcomes in 'trial 2'. Since each trial has six outcomes, it follows that the number of outcomes (i.e. possible distinct pairs) is ${\displaystyle 6\cdot 6=36}$.

${\displaystyle \Box }$

Exercise.

Suppose the red dice becomes a blue dice, such that the two dices are not distinguishable anymore. Calculate the number of possible distinct pairs of number facing up.

 6 15 18 21 36

## Number of ways to select some objects from distinguishable objects

In this section, we will discuss number (no.) of ways to select some objects from distinguishable objects, in four types, classified by whether the selection is ordered, and whether the selection is with replacement.

Before discussing these four types of selection, we will introduce some preliminary mathematical concepts used in the following.

### Preliminary mathematical concepts

Definition. (Factorial) For each nonnegative integer ${\displaystyle n}$, the factorial of ${\displaystyle n}$, denoted by ${\displaystyle n!}$, is

${\displaystyle n!={\begin{cases}1,&n=0;\\n(n-1)\dotsb (1),&n\geq 1.\end{cases}}}$

More generally, we have gamma function.

Definition. (Gamma function) The gamma function is

${\displaystyle \Gamma (x)=\int _{0}^{\infty }y^{x-1}e^{-y}\,dy,}$
in which ${\displaystyle x>0}$.

Proposition. (Relationship between gamma function and factorial) For each nonnegative integer ${\displaystyle n}$, ${\displaystyle \Gamma (n+1)=n!}$.

Proof. Using integration by parts,

{\displaystyle {\begin{aligned}\Gamma (x+1)&=\int _{0}^{\infty }y^{x}e^{-y}\,dy\\&=\int _{0}^{\infty }y^{x}\,d(-e^{-y})\\&=\left[-y^{x}e^{-y}\right]_{y=0}^{y=\infty }+\int _{0}^{\infty }e^{-y}\,d(y^{x})\\&=\left[-y^{x}e^{-y}\right]_{y=0}^{y=\infty }+x\underbrace {\int _{0}^{\infty }y^{x-1}e^{-y}\,dy} _{\Gamma (x)}\\&=0-0+x\Gamma (x)\qquad {\text{since }}e^{-y}\to 0{\text{ as }}y\to \infty \\&=x\Gamma (x).\end{aligned}}}
Since
${\displaystyle \Gamma (1)=\int _{0}^{\infty }y^{1-1}e^{-y}\,dy=\left[-e^{-y}\right]_{0}^{\infty }=0-(-1)=1,}$
${\displaystyle \Gamma (n+1)=n\Gamma (n)=\dotsb =n(n-1)\cdots (1)\Gamma (1)=n(n-1)\cdots (1)=n!}$
for each nonnegative integer ${\displaystyle n}$.

${\displaystyle \Box }$

Remark.

• The infinity in the proof can be regarded as extended real number, or be in limit sense.
• Another more general result shown in the proof is that ${\displaystyle \Gamma (x+1)=x\Gamma (x)}$ for each positive ${\displaystyle x}$.

Definition. (Binomial coefficient) The binomial coefficient, indexed by nonegative integers ${\displaystyle n}$ and ${\displaystyle r}$ such that ${\displaystyle n\geq r}$. denoted by ${\displaystyle {\binom {n}{r}}}$, is

${\displaystyle {\binom {n}{r}}={\frac {n!}{r!(n-r)!}}.}$

Theorem. (Binomial series theorem) For each real number ${\displaystyle \alpha }$,

${\displaystyle (1+x)^{\alpha }=1+\alpha x+{\frac {\alpha (\alpha -1)}{2!}}x^{2}+{\frac {\alpha (\alpha -1)(\alpha -2)}{3!}}x^{3}+\dotsb ,}$
in which ${\displaystyle |x|<1}$.

Remark. The following are some special cases of this theorem:

• ${\displaystyle (1+x)^{-1}=1-x+x^{2}-x^{3}+\dotsb }$;
• ${\displaystyle (1-x)^{-1}=1+x+x^{2}+x^{3}+\dotsb }$;
• ${\displaystyle (1+x)^{-n}=\sum _{r=0}^{\infty }{\binom {n+r-1}{r}}x^{r}}$ (negative binomial series);
• ${\displaystyle (1+x)^{n}=1+{\binom {n}{1}}x+{\binom {n}{2}}x^{2}+\dotsb +{\binom {n}{n}}x^{n}+\underbrace {{\frac {n(n-1)\dotsb (\overbrace {\color {darkgreen}n-n)} ^{=0}}{n!}}+\dotsb } _{=0}=\sum _{r=0}^{n}{\binom {n}{r}}x^{r}}$ (binomial series).

Theorem. (Binomial theorem) For each nonegative integer ${\displaystyle n}$,

${\displaystyle (x+y)^{n}={\binom {n}{\color {darkgreen}0}}x^{n}y^{\color {darkgreen}0}+{\binom {n}{\color {darkgreen}1}}x^{n-{\color {darkgreen}1}}y^{\color {darkgreen}1}+\dotsb +{\binom {n}{\color {darkgreen}n}}x^{n-{\color {darkgreen}n}}y^{\color {darkgreen}n}.}$

Proof. It can be proved combinatorially or inductively. Complete proof is omitted.

${\displaystyle \Box }$

The binomial theorem can be illustrated by Pascal's triangle:

${\displaystyle {\begin{array}{lc}(a+b)^{0}=&{\color {Red}{\boldsymbol {1}}}\\(a+b)^{1}=&{\color {Red}{\boldsymbol {1}}}a+{\color {Red}{\boldsymbol {1}}}b\\(a+b)^{2}=&{\color {Red}{\boldsymbol {1}}}a^{2}+{\color {Red}{\boldsymbol {2}}}ab+{\color {Red}{\boldsymbol {1}}}b^{2}\\(a+b)^{3}=&{\color {Red}{\boldsymbol {1}}}a^{3}+{\color {Red}{\boldsymbol {3}}}a^{2}b+{\color {Red}{\boldsymbol {3}}}ab^{2}+{\color {Red}{\boldsymbol {1}}}b^{3}\\(a+b)^{4}=&{\color {Red}{\boldsymbol {1}}}a^{4}+{\color {Red}{\boldsymbol {4}}}a^{3}b+{\color {Red}{\boldsymbol {6}}}a^{2}b^{2}+{\color {Red}{\boldsymbol {4}}}ab^{3}+{\color {Red}{\boldsymbol {1}}}b^{4}\\\end{array}}}$ ${\displaystyle {\begin{array}{c}{\color {Red}{\boldsymbol {1}}}={\binom {0}{0}}\\{\color {Red}{\boldsymbol {1}}}={\binom {1}{0}}\quad \quad {\color {Red}{\boldsymbol {1}}}={\binom {1}{1}}\\{\color {Red}{\boldsymbol {1}}}={\binom {2}{0}}\quad \quad {\color {Red}{\boldsymbol {2}}}={\binom {2}{1}}\quad \quad {\color {Red}{\boldsymbol {1}}}={\binom {2}{2}}\\{\color {Red}{\boldsymbol {1}}}={\binom {3}{0}}\quad \quad {\color {Red}{\boldsymbol {3}}}={\binom {3}{1}}\quad \quad {\color {Red}{\boldsymbol {3}}}={\binom {3}{2}}\quad \quad \quad \quad {\color {Red}{\boldsymbol {1}}}={\binom {3}{3}}\\{\color {Red}{\boldsymbol {1}}}={\binom {4}{0}}\quad \quad {\color {Red}{\boldsymbol {4}}}={\binom {4}{1}}\quad \quad {\color {Red}{\boldsymbol {6}}}={\binom {4}{2}}\quad \quad {\color {Red}{\boldsymbol {4}}}={\binom {4}{3}}\quad \quad {\color {Red}{\boldsymbol {1}}}={\binom {4}{4}}\\\end{array}}}$

### Ordered selection without replacement

Theorem. The no. of ways for ordered selection of ${\displaystyle r\leq n}$ objects from ${\displaystyle n}$ distinguishable objects without replacement is ${\displaystyle n!/(n-r)!}$

Proof. Consider an equivalent situation: selecting ${\displaystyle r\leq n}$ objects from ${\displaystyle n}$ distinguishable objects to be put into ${\displaystyle r}$ ordered boxes, labelled box ${\displaystyle 1,2,\dotsc ,r}$, in which each box contains at most one object. By considering the ${\displaystyle r}$ boxes from box 1 to box ${\displaystyle r}$ ,

• for box 1, there are ${\displaystyle n}$ choices of object to be put into it
• for box 2, there are ${\displaystyle n-1}$ choices of object to be put into it, since the object put into box 1 cannot be simultaneously put into box 2
• ...
• for box ${\displaystyle r}$, there are ${\displaystyle n-(r-1)=n-r+1}$ choices of object to be put into it, since each of the ${\displaystyle r-1}$ objects put into box ${\displaystyle 1,2,\dotsc ,r-1}$ cannot be simultaneously put into box ${\displaystyle r}$

Thus, by multiplication principle of counting, the desired no. of ways is

${\displaystyle \underbrace {n} _{\text{box 1}}\times \underbrace {(n-1)} _{\text{box 2}}\times \dotsb \times \underbrace {(n-r+1)} _{{\text{box }}r}={\frac {n\times (n-1)\times \dotsb \times (n-r+1)\times {\color {darkgreen}(n-r)\times \cdots \times 1}}{\color {darkgreen}(n-r)\times \cdots \times 1}}={\frac {n!}{(n-r)!}}}$

${\displaystyle \Box }$

Remark.

• ${\displaystyle n!/(n-r)!}$ is often denoted by ${\displaystyle _{n}P_{r}}$ (read n p r).

Example. The no. of distinct ways to select 3 objects to be put into 3 boxes, labelled ${\displaystyle B_{1},B_{2}}$ and ${\displaystyle B_{3}}$ from 5 objects, labelled ${\displaystyle O_{1},O_{2},O_{3},O_{4}}$ and ${\displaystyle O_{5}}$ is ${\displaystyle {\frac {5!}{(5-3)!}}=\underbrace {5} _{B_{1}}\times \underbrace {4} _{B_{2}}\times \underbrace {3} _{B_{3}}=60.}$

Exercise.

1 After putting the 3 objects into the 3 boxes, 2 of them are taken out and put into 2 boxes, labelled ${\displaystyle B_{4}}$ and ${\displaystyle B_{5}}$. Calculate the no. of distinct ways to do this.

 3 6 60 180 360

2 Continue from previous question. Suppose only 1 of them is taken out and put into 1 box, labelled ${\displaystyle B_{4}}$, now. Calculate the no. of distinct ways to do this.

 3 6 60 180 360

Example. (Competition) There are ${\displaystyle 16}$ candidates for a competition. The no. of ways to award winner, 1st and 2nd runners-up is ${\displaystyle {\frac {16!}{(16-3)!}}=\underbrace {16} _{\text{winner}}\times \underbrace {15} _{\text{1st runner-up}}\times \underbrace {14} _{\text{2nd runner-up}}=3360.}$

If, Amy and Bob are among the ${\displaystyle 16}$ candidates, and it is given that Amy is awarded 1st runner-up, while Bob does not receive any award, the no. of ways to award winner, 1st and 2nd runners-up becomes ${\displaystyle {\frac {14!}{(14-2)!}}\times 1=\underbrace {14} _{\text{winner}}\times \underbrace {1} _{\text{1st runner-up: Amy}}\times \underbrace {13} _{\text{2nd runner-up}}=182}$. In particular, Amy and Bob cannot be awarded winner or 2nd runner-up.

Exercise.

1 Suppose Chris is also among the ${\displaystyle 16}$ candidates. Given that Amy, Bob and Chris receive an award from the competition, calculate the no. of ways to award winner, 1st and 2nd-runners up.

 1 3 6 32 96

2 Continue from previous question. Given that Amy, Bob and Chris do not receive any award from the competition, calculate the no. of ways to award winner, 1st and 2nd-runners up.

 1716 2496 3354 3357 3359

A special case of ordered selection without replacement is when the no. of selected objects equals the no. of objects to be selected. In this case, this selection is called permutation, and the no. of ways for permutation of ${\displaystyle n}$ objects (i.e. ordered selection of ${\displaystyle n}$ objects from ${\displaystyle n}$ objects) is ${\displaystyle n!/(n-n)!=n!}$.

Example.

Figure 6. 3!=3·2·1= 6 permutations of {1,2,3}.

The 6 ways to permute the string 123 are shown in Figure 6.

### Unordered selection of distinguishable objects without replacement

Theorem. The no. of ways for unordered selection to select ${\displaystyle r\leq n}$ objects from ${\displaystyle n}$ distinguishable objects without replacement is ${\displaystyle {\frac {n!}{r!(n-r)!}}={\binom {n}{r}}}$.

Proof. There are two ways to prove this.

First, consider an equivalent situation: selecting ${\displaystyle r\leq n}$ objects from ${\displaystyle n}$ distinguishable objects without replacement to be put into one box [1]. Then, we consider the no. of ways to do this in order, and then remove some ways that are regarded to be the same for unordered selection (i.e. regarded as the same when we put the objects into one box). The no. of ways to do this in order is ${\displaystyle \underbrace {n} _{\text{choice 1}}\times \underbrace {n-1} _{\text{choice 2}}\times \dotsb \times \underbrace {n-r+1} _{{\text{choice }}r}={\frac {n!}{(n-r)!}}}$ (choice ${\displaystyle k}$ means the ${\displaystyle k}$th selection of objects to be put into the box)

Among these ways, putting the same ${\displaystyle r}$ objects into the box in different orders counts as different ways, and we need to merge them together, into one way. To merge them, we consider how many different ways are counted for putting the same ${\displaystyle r}$ objects into the box in different orders. Indeed, this is permutation (ordered selection of ${\displaystyle r}$ objects from ${\displaystyle r}$ distinguishable objects), so the no. of different ways is ${\displaystyle r!}$. So, we count ${\displaystyle r!}$ extra times of no. of ways (i.e. scale up the no. of ways by a factor ${\displaystyle r!}$) , and thus we need to scale down the no. of ways, by dividing the no. by ${\displaystyle r!}$. Thus, the desired no. of ways is ${\displaystyle {\frac {n!}{r!(n-r)!}}={\binom {n}{r}}}$.

Second, we use the notion of generating function, by encoding the selection process into a binomial series, and then use the coefficients to determine the desired no. of ways. To be more precise, recall a special case of binomial series theorem:

${\displaystyle \underbrace {(1+x)(1+x)\dotsb (1+x)} _{n{\text{ times}}}(1+x)^{n}=1+\cdots +{\binom {n}{r}}x^{r}+\cdots +{\binom {n}{n}}x^{n}.}$
By encoding each selection to each of ${\displaystyle (1+x)}$, through treating the ${\displaystyle x^{0}=1}$ and ${\displaystyle x^{1}=x}$ in the ${\displaystyle k}$th ${\displaystyle (1+x)}$ as not selecting the object and selecting the object respectively, the coefficient of ${\displaystyle x^{r}}$ is the desired no. of ways, since it is the no. of ways to build ${\displaystyle x^{r}}$, through selecting ${\displaystyle x}$ in ${\displaystyle r}$ ${\displaystyle (1+x)}$'s, and selecting 1 in other ${\displaystyle (1+x)}$'s (i.e. selecting ${\displaystyle r}$ objects, regardless of the order). Thus, the desired no. of ways is ${\displaystyle {\binom {n}{r}}}$.

${\displaystyle \Box }$

Remark.

• The unordered selection without replacement is also known as combination.
• ${\displaystyle {\binom {n}{r}}}$ is read as 'n choose r', or 'n c r'.

Example.

Figure 8: ${\displaystyle C(n,k)}$ is shown for ${\displaystyle n=3,}$ and ${\displaystyle k=0,1,2,3.}$ The dotted ellipses remind us that these are sets, where order is not important.

For combination, the order in which the items are selected are not important, so each selection from a set can be regarded as a subset of the original set. Figure 8 illustrates for the set ${\displaystyle \{1,2,3\}.}$ The number of elements in this set is ${\displaystyle n=3.}$ From our earlier discussion of the power set, we know that the total number of subsets is ${\displaystyle 2^{3}=8}$. All 8 subsets are shown in the figure, organized by how many items are in each subset (for example, the subset in the upper-left corner contains 3 elements, while all subsets with 2 elements occupy the lower-right corner.) Let ${\displaystyle k}$ denote the number of elements "chosen" to be in each of the 8 subsets of set ${\displaystyle S=\{1,2,3\}}$ (where the number of elements in ${\displaystyle S}$ is, ${\displaystyle n=3}$.)

• ${\displaystyle {\binom {3}{0}}=1}$ set has ${\displaystyle k=0}$ elements. It is the empty set: ${\displaystyle \varnothing }$.
• ${\displaystyle {\binom {3}{1}}=3}$ sets have ${\displaystyle k=1}$ element. They are ${\displaystyle \{1\}}$,${\displaystyle \{2\}}$,and ${\displaystyle \{3\}}$.
• ${\displaystyle {\binom {3}{2}}=3}$ sets have ${\displaystyle k=2}$ elements. They are ${\displaystyle \{2,3\}}$,${\displaystyle \{1,3\}}$,and ${\displaystyle \{1,2\}}$.
• ${\displaystyle {\binom {3}{3}}=1}$ set has ${\displaystyle k=3}$ elements. It is the set itself: ${\displaystyle \{1,2,3\}}$.

Example.

Figure 9: combinations. ${\displaystyle {\textit {4-choose-2}}}$ ${\displaystyle =6}$

No. of ways to select 2 objects from 4 distinguishable objects without considering the order is ${\displaystyle {\binom {4}{2}}=6}$

Example. (Competition) There are 16 candidates for a competition. The no. of ways to select 3 candidates to enter final is ${\displaystyle {\binom {16}{3}}={\frac {16\times 15\times 14}{3\times 2\times 1}}=560.}$

Exercise.

1 Amy, Bob and Chris are among the ${\displaystyle 16}$ candidates. Calculate the no. of ways to select them to enter final.

 1 3 6 32 96

2 Continue from the previous question. Calculate the no. of ways to select candidates other than Amy, Bob and Chris to enter final.

 220 286 554 557 559

#### Special cases worth remembering

The formula for counting combinations has special cases that are worth remembering:

• ${\displaystyle {\binom {n}{0}}={\binom {n}{n}}=1}$ (There is only one way to pick no thing and only one way to pick all ${\displaystyle n}$ things.)
• ${\displaystyle {\binom {n}{1}}={\binom {n}{n-1}}=n}$ (there are n ways to pick one thing or to leave one thing out)
• ${\displaystyle {\binom {n}{k}}={\binom {n}{n-k}}}$ (There are the same number of ways of picking ${\displaystyle k}$ of ${\displaystyle n}$ things as there are of leaving out ${\displaystyle k}$ of ${\displaystyle n}$ things)

### Ordered selection of distinguishable objects with replacement

Theorem. The no. of ways for selecting ${\displaystyle r}$ objects from ${\displaystyle n}$ distinguishable objects in order, with replacement is ${\displaystyle n^{r}}$.

Proof. Consider the equivalent situation: selecting ${\displaystyle r}$ objects from ${\displaystyle n}$ types of objects, in which each type of the objects has unlimited stock, to be put into ${\displaystyle r}$ ordered boxes (the same object may be selected more than once). Then, the no. of ways is ${\displaystyle \underbrace {n} _{\text{box 1}}\times \underbrace {n} _{\text{box 2}}\times \dotsb \times \underbrace {n} _{{\text{box }}r}=n^{r}}$, since for each box, there are ${\displaystyle n}$ types of objects that can be selected to be put into it.

${\displaystyle \Box }$

Remark.

• ${\displaystyle r}$ can be greater than ${\displaystyle n}$.

Example. (Setting password) The number of ways to set a password with 6 characters, with the following rules:

(R1) numbers are allowed
(R2) alphabets are allowed, and they are case-sensitive [2]
(R3) special characters (i.e. all characters other than numbers and alphabets) are not allowed

is ${\displaystyle \underbrace {62} _{\text{1st position}}\times \underbrace {62} _{\text{2nd position}}\times \dotsb \times \underbrace {62} _{\text{6th position}}=62^{6}=56800235584.}$

Proof. For each of the 6 positions available for the password, there are ${\displaystyle \underbrace {2} _{\text{cases}}\times \underbrace {26} _{\text{alphabets}}+\underbrace {10} _{\text{numbers}}=62}$ choices of characters. Also, the characters can be repeated in more than one positions, and order matters. So, this is a case of ordered selection of distinguishable objects with replacement. Thus, the desired number is ${\displaystyle \underbrace {62} _{\text{1st position}}\times \underbrace {62} _{\text{2nd position}}\times \dotsb \times \underbrace {62} _{\text{6th position}}=62^{6}=56800235584.}$

${\displaystyle \Box }$

Exercise.

1 Suppose a machine can have ${\displaystyle 3.5\times 10^{11}}$ password guesses per second. Approximate the maximum time needed for the machine to guess the six-character password correctly using the formula

${\displaystyle {\text{the maximum time needed}}\approx {\frac {\text{number of ways to set the password}}{\text{guessing speed}}}.}$
(correct to two decimal places)

 0.00 seconds 0.15 seconds 0.16 seconds 6.16 seconds 369.72 seconds

2 Suppose the password is safe if the maximum time needed for the machine to guess the password correctly, using the same formula in the previous question, is greater than or equal to 100 years (i.e. ${\displaystyle 100\times 365.25\times 24\times 3600=3155760000}$ seconds). The minimum number of characters needed for the password (with the same rules) to be safe is

 not greater than 10. greater than 10 but not greater than 15. greater than 10 but not greater than 20. greater than 20 but not greater than 25. greater than 25.

### Unordered selection of distinguishable objects with replacement

This type of selection is probably the most complicated.

Theorem. The number of ways for unordered selection of ${\displaystyle r}$ objects from ${\displaystyle n}$ distinguishable objects with replacement is ${\displaystyle {\binom {n+r-1}{r}}={\frac {(n+r-1)!}{r!(n-1)!}}}$.

Proof. There are two ways to prove this.

First, consider an equivalent situation: selecting ${\displaystyle r}$ objects from ${\displaystyle n}$ types of objects, in which each type of the objects has unlimited stock, to be put into one box (the same object may be selected more than once). Then, we use the stars and bars notation: e.g.

*|**|*|...|*||**|*


in which ${\displaystyle k}$th gap created by the bars corresponds to the ${\displaystyle k}$th type of object (the leftmost gap made by one bar is the 1st gap, the rightmost gap made by one bar is the last gap), and the number of * in each gaps represents the number of objects selected for the corresponding type of objects. E.g., 2 * in 2nd gap represents the 2 objects are selected from the 2nd type of objects. Then, the desired no. of ways is the no. of arrangements of ${\displaystyle r}$ * and ${\displaystyle n-1}$ bars [3], which is the no. of ways to select ${\displaystyle r}$ from ${\displaystyle n-1+r}$ positions for * [4] (order does not matter), calculated by ${\displaystyle {\binom {n+r-1}{r}}}$.

Second, we use the notion of generating function, by encoding the selection as follows:

• encoding the selection of each type of objects to ${\displaystyle (1+x+x^{2}+\dotsb )}$, by treating ${\displaystyle x^{0}=1}$, ${\displaystyle x^{1}=1}$, ${\displaystyle x^{2}}$, etc. (up to ${\displaystyle x^{r})}$ in the ${\displaystyle k}$ th ${\displaystyle (1+x+x^{2}+\cdots )}$ as selecting 0, 1, 2, etc. (up to ${\displaystyle r}$) objects from the ${\displaystyle k}$ th type respectively

Then, the desired no. is the coefficient of ${\displaystyle x^{r}}$ in

${\displaystyle \underbrace {(1+x+x^{2}+\dotsb )(1+x+x^{2}+\cdots )\cdots (1+x+x^{2}+\cdots )} _{n{\text{ times}}}=\underbrace {(1-x)^{-1}(1-x)^{-1}\dotsb (1-x)^{-1}} _{n{\text{ times}}}=(1-x)^{-n}.}$
[5] By binomial series theorem, the coefficient of ${\displaystyle x^{r}}$ is
${\displaystyle {\frac {(-n)(-n-1)\dotsb (-n-r+1)}{r!}}(-1)^{r}={\frac {(-1)^{r}(n)(n+1)\dotsb (n+r-1)}{r!}}(-1)^{r}={\frac {(n+r-1)\dotsb (n+1)(n)}{r!}}={\binom {n+r-1}{r}}.}$

${\displaystyle \Box }$

Remark.

• ${\displaystyle r}$ can be greater than ${\displaystyle n}$.
• ${\displaystyle {\binom {n+r-1}{r}}}$ is often denoted by ${\displaystyle _{n}H_{r}}$ (read 'n h r')

Example. There are 8 distinct food or drink items, namely hamburger, egg, fries, cake, apple pie, apple juice, orange juice and coke. The number of distinct 4-item combos that must consist of distinct items (unordered selection without replacement) is ${\displaystyle {\binom {8}{4}}=70}$, and that without restrictions (particularly, may consist of more than one same item) (unordered selection with replacement) is ${\displaystyle {\binom {8+4-1}{4}}=330}$.

Exercise.

1 Calculate the no. of distinct 4-item combos that must consist of 3 food items (which may be the same) and 1 drink item.

 12 35 38 105 330

2 Calculate the no. of distinct 4-item combos that contain no drinks.

 5 70 126 280 330

3 Suppose each food or drink item only has 2 left in the stock. Calculate the no. of distinct 4-item combos without restrictions. (Hint: ${\displaystyle (1+x+x^{2})^{4}=1+4x+10x^{2}+16x^{3}+19x^{4}+{\text{terms with order higher than }}x^{4}}$)

 19 45 183 266 330

4 Suppose each food costs $10, while each drink costs$5. Calculate the no. of distinct \$20 combos without restrictions. (Hint: calculator should be used to ease the calculation)

 15 30 60 121 225

5 Amy loves eating hamburger very much, so she must choose two hamburgers when she chooses the items for the 4-item combos. Calculate the no. of distinct ways for Amy to order a 4-item combo without restriction.

 6 15 28 36 210

Example. (Number of integer solutions of a equation) The number of solutions to

${\displaystyle x_{1}+x_{2}+\dotsb +x_{7}=10}$
in which ${\displaystyle x_{1},\dotsc ,x_{7}}$ are nonegative integers, is ${\displaystyle {\binom {7+10-1}{10}}=8008}$.

Proof. Consider the following stars and bars graph:

|**|*|**|*|**|**


in which the no. of stars is 10, corresponding to the number at RHS of the equation, and no. of gaps created by the bars is 7, corresponding to the number of unknowns at LHS of the equation. The no. of stars in each gap represents the (nonnegative) number assigned to that unknown. So, the number of solutions is the no. of arrangements of these stars and bars, namely ${\displaystyle {\binom {7+10-1}{10}}=8008.}$

Alternatively, we can interpret there are 10 (no. at RHS) balls selected from 7 (no. of unknowns at LHS) types of balls, labelled ${\displaystyle x_{1},\dotsc ,x_{7}}$, with unlimited stock, to be put into a box, in which the number of balls labelled ${\displaystyle x_{1},\dotsc ,x_{7}}$ in the box represents the number assigned for the unknowns ${\displaystyle x_{1},\dotsc ,x_{7}}$ respectively. Then, the no. of solutions is the no. of ways to do this, namely ${\displaystyle {\binom {7+10-1}{10}}}$.

${\displaystyle \Box }$

Exercise.

1 Calculate the number of solutions if ${\displaystyle x_{1},\dotsc ,x_{7}}$ are positive integers instead. (Hint: letting ${\displaystyle x_{1}'=x_{1}+1}$, then ${\displaystyle x_{1}'}$ is a nonnegative integer)

 28 56 84 560 5005

2 Calculate the number of solutions if the '${\displaystyle =}$' sign is changed to '${\displaystyle <}$' sign, i.e. the number of solutions to ${\displaystyle x_{1}+\dotsb +x_{7}<10}$ in which ${\displaystyle x_{1},\dotsc ,x_{7}}$ are nonnegative integers. (Hint: add one more positive integer unknown to LHS, so that the '${\displaystyle <}$' sign becomes '${\displaystyle =}$' sign)

 3003 5005 6435 11440 19448

### Summary

Selecting ${\displaystyle r}$[6] objects from ${\displaystyle n}$ distinguishable objects
with replacement without replacement
ordered
${\displaystyle n^{r}}$
${\displaystyle {\frac {n!}{(n-r)!}}}$
unordered
${\displaystyle {\binom {n+r-1}{r}}}$
${\displaystyle {\binom {n}{r}}}$

Exercise. Try to prove each of the above formulas, without looking the previous subsections. After that, you can compare your proofs against the proofs in the previous subsections.

## Partitions

Theorem. The number of ways to partition ${\displaystyle n}$ distinguishable objects into ${\displaystyle k}$ groups with group ${\displaystyle 1,\dotsc ,k}$ containing exactly ${\displaystyle n_{1},\dotsc ,n_{k}}$ objects respectively (order does not matter) is ${\displaystyle {\frac {n!}{n_{1}!n_{2}!\dotsb n_{k}!}}}$.

Proof. There are two ways to prove this.

First, consider an equivalent situation: putting ${\displaystyle n_{1},\dotsc ,n_{k}}$ objects selected from ${\displaystyle n}$ distinguishable objects into box ${\displaystyle 1,\dotsc ,k}$ respectively.

Then, consider the boxes one by one:

• box 1: ${\displaystyle n_{1}}$ objects selected from ${\displaystyle n}$ distinguishable objects to be put into it, so no. of ways is ${\displaystyle {\binom {n}{n_{1}}}}$
• box 2: ${\displaystyle n_{2}}$ objects selected from ${\displaystyle n-n_{1}}$ distinguishable objects [7], so no. of ways is ${\displaystyle {\binom {n-n_{1}}{n_{2}}}}$
• ...
• box ${\displaystyle k}$: ${\displaystyle n_{k}}$ objects selected from ${\displaystyle n-n_{1}-\dotsb -n_{k-1}}$ [8] to be put into it, so no. of ways is ${\displaystyle {\binom {n-n_{1}-\cdots -n_{k-1}}{n_{k}}}}$

By multiplication principle of counting, the no. of ways for the whole process is

{\displaystyle {\begin{aligned}{\binom {n}{n_{1}}}{\binom {n-n_{1}}{n_{2}}}\dotsb {\binom {n-n_{1}-\cdots -n_{k-1}}{n_{1}}}&={\frac {n!}{n_{1}!{\color {darkgreen}{\cancel {(n-n_{1})!}}}}}\cdot {\frac {\color {darkgreen}{\cancel {(n-n_{1})!}}}{n_{2}!{\color {blue}{\cancel {(n-n_{1}-n_{2})!}}}}}\cdot {\frac {\color {blue}{\cancel {(n-n_{1}-n_{2})!}}}{n_{3}!{\color {red}{\cancel {(n-n_{1}-n_{2}-n_{3})!}}}}}\cdot {\frac {\color {purple}{\cancel {(n-n_{1}-n_{2}-\dotsb -n_{k-1})!}}}{n_{k}!(n-\underbrace {n_{1}-n_{2}-n_{3}-\cdots -n_{k}} _{=n})!}}\\&={\frac {n!}{n_{1}!n_{2}!n_{3}!\dotsb n_{k}!\underbrace {0!} _{=1}}}\\&={\frac {n!}{n_{1}!n_{2}!\dotsb n_{k}!}}.\end{aligned}}}

Second, we use the notion of generating function, by encoding the partition process as follows:

• in the ${\displaystyle m}$th ${\displaystyle (x_{1}+x_{2}+\dotsb +x_{k})}$, ${\displaystyle x_{1},\dotsc ,x_{k}}$ represents the ${\displaystyle m}$th object is put into box ${\displaystyle 1,\dotsc ,k}$ respectively

Then, the desired no. of ways is the coefficient of ${\displaystyle x_{1}^{n_{1}}\dotsb x_{k}^{n_{k}}}$ in ${\displaystyle (x_{1}+x_{2}+\cdots +x_{k})(x_{1}+x_{2}+\cdots +x_{k})\cdots }$, which is ${\displaystyle {\frac {n!}{n_{1}!n_{2}!\dotsb n_{k}!}}}$, by multinomial theorem (generalized version of binomial theorem) [9].

${\displaystyle \Box }$

Remark.

• partitioning objects into two groups is the same as unordered selection without replacement [10]
• ${\displaystyle {\frac {n!}{n_{1}!n_{2}!\dotsb n_{k}!}}}$ is called the multinomial coefficient, and is denoted by ${\displaystyle {\binom {n}{n_{1},n_{2},\dotsc ,n_{k}}}}$

Example. (Sequence of dice outcomes) A six-faced dice is rolled nine times. The number of distinct sequences in which 1,3 and 5 each comes up three times is${\displaystyle {\frac {9!}{3!3!3!}}=1680}$.

Proof. Consider this situation as the partition of the nine (ordered) outcomes from the die to three groups, which represents 1,3 and 5 comes up in that outcome respectively. The three groups contains 3 outcomes each, so that each odd number comes up three times. It follows that the number of ways to partition the outcomes is ${\displaystyle {\frac {9!}{3!3!3!}}}$.

For each partition of outcomes into different groups, we obtain a unique sequence of outcomes. [11]

${\displaystyle \Box }$

Exercise.

1 Calculate the number of distinct sequences in which 2,4 and 6 each comes up three times instead.

 840 1680 3360 6720 361200

2 Suppose we throw the die 12 times instead. Calculate the number of distinct sequences in which each number comes up two times.

 2520 5040 113400 369600 7484400

Example. (Arrangement of letters) The number of letter arrangements of the word PROBABILITY is ${\displaystyle {\binom {11}{2,2,1,1,1,1,1,1,1}}=9979200}$.

Proof. The word PROBABILITY has 2 letter B's and 2 letter I's. For other letters, they appear only once. So, we partition the 11 letter positions in the word into 9 groups, representing letter P,R,O,B,A,I,L,T and Y, respectively, and the group representing letter B and I contain 2 letter positions each, and other groups contain 1 letter position each.

${\displaystyle \Box }$

Exercise.

1 Calculate the number of letter arrangements of the word EXERCISE.

 28 56 3360 6720 20160

2 Calculate number of number arrangements of the number 171237615, such that the number formed is a odd number.

 6720 11760 13440 23520 161280

Example. (Walking path) Consider the following diagram.

${\displaystyle {\begin{array}{c|c|c|c|c}A&&&&B\\\hline &&E&&\\\hline C&&&&D\\\end{array}}}$
Suppose we are initially located at ${\displaystyle A}$, and that we can only walk either one cell rightward or one cell downward for each step. The number of distinct sequence of steps such that we can walk from ${\displaystyle A}$ to ${\displaystyle D}$ is ${\displaystyle \underbrace {6} _{\text{steps}}!/(\underbrace {2} _{\downarrow }!\underbrace {4} _{\rightarrow }!)=15.}$

Proof. First, observe that we need 6 and only 6 steps to walk from ${\displaystyle A}$ to ${\displaystyle D}$ [12], consisting 4 steps of walking rightward (${\displaystyle \rightarrow }$) and 2 steps of walking downward (${\displaystyle \downarrow }$).

Thus, the number of distinct sequence of steps is equivalent to the number of distinct sequence of 4 ${\displaystyle \rightarrow }$'s and 2 ${\displaystyle \downarrow }$'s.

A way to calculate this is to consider this as a partition problem: partition the 6 step positions into 2 groups, one of them represents ${\displaystyle \rightarrow }$ (and contains 4 step positions), another represents ${\displaystyle \downarrow }$ (and contains 2 step positions).

Alternatively, we can consider this as combination: unordered selection of 4 step positions for ${\displaystyle \rightarrow }$ (then the remaining is for ${\displaystyle \downarrow }$).

The result follows.

${\displaystyle \Box }$

Exercise.

1 Calculate the number of distinct sequence again if we can also walk one cell leftward.

 15 35 90 105 none of the above

2 Calculate the number of distinct sequence if we also need to walk through ${\displaystyle E}$ in the walking process from ${\displaystyle A}$ to ${\displaystyle D}$ (Hint: consider this as walking from ${\displaystyle A}$ to ${\displaystyle E}$, then from ${\displaystyle E}$ to ${\displaystyle D}$).

 9 10 11 12 none of the above

3 Calculate the number of distinct sequence if we cannot walk through ${\displaystyle C}$ in the walking process.

 7 8 9 10 none of the above

4 Suppose Amy and Bob is initially located at ${\displaystyle A}$ and ${\displaystyle b}$ respectively. Calculate the number of distinct sequence of steps for Amy such that Amy and Bob meet at ${\displaystyle E}$, given that Amy can only walk 1 cell rightward or 1 cell downward for each step, while Bob can only walk 1 cell leftward or 1 cell downward for each step.

 3 6 9 12 none of the above

## Exercises

### Lottery tickets

Example. (Pick 3 Texas Lottery) The Texas Lottery game Pick 3 is easy to play. A player must pick three numbers from zero to nine, and choose how to play them: exact order, or any order. The Pick 3 balls are drawn using three air-driven machines. These machines use compressed air to mix and select each ball.

The probability of winning while playing the exact order is

${\displaystyle {\frac {1}{10}}{\frac {1}{10}}{\frac {1}{10}}={\frac {1}{1000}}.}$

The probability of winning while playing any order depends on the numbers selected. If three distinct numbers are selected then the probability of winning is 3/500. If a number is repeated twice, the probability of winning is 3/1000. While, if the same number is selected three times, the probability of winning becomes 1/1000.

Example. (Mega Millions Texas Lottery) To play the Mega Millions game, a player must select five numbers from 1 to 56 in the upper white play area of the play board, and one Mega Ball number from 1 to 46 in the lower yellow play area of the play board.

All drawing equipment is stored in a secured on-site storage room. Only authorized drawings department personnel have keys to this door. Upon entry of the secured room to begin the drawing process, a lottery drawing specialist examines the security seal to determine if any unauthorized access has occurred. For each drawing, the Lotto Texas balls are mixed by four acrylic mixing paddles rotating clockwise. High speed is used for mixing and low speed for ball selection. As each ball is selected, it rolls down a chute into an official number display area. We wish to compute the probability of winning the Mega Millions Grand Prize, which require the correct selection of the five white balls plus the gold Mega ball. The probability of winning the Mega Millions Grand Prize is

${\displaystyle {\frac {51!5!}{56!}}{\frac {1}{46}}={\frac {1}{175711536}}.}$

## References and footnotes

1. since we put the objects into one box, the order of putting the objects does not matter (we only know which ${\displaystyle r}$ objects are put into the box, but do not know in what order)
2. e.g., A ${\displaystyle \neq }$ a
3. ${\displaystyle n-1}$ bars create ${\displaystyle n-1+1=n}$ gaps
4. or select ${\displaystyle n-1}$ from ${\displaystyle n-1+r}$ positions for bars, and the no. of ways for these two are the same
5. the terms with order higher than ${\displaystyle r}$, e.g. ${\displaystyle x^{r+1}}$, do not affect the coefficient of ${\displaystyle x^{r}}$, since there is not term with negative power. So, for convenience, we can include those terms with higher orders without affecting the result.
6. with value such that the following terms are defined
7. the objects put into box 1 cannot be simultaneously to be put into it
8. the objects put into boxes ${\displaystyle 1,\dotsc ,k-1}$ cannot be simultaneously to be put into it
9. the theorem itself is not our main focus here
10. one group contains the objects selected, and another group contains the objects unselected
11. E.g. if we put 1st, 2nd and 4th outcomes to the group representing 1 coming up, 5th, 7th and 9th outcomes to the group representing 3 coming up, and the remaining outcomes are put to the group representing 5 coming up, then the sequence obtained is: (1st outcome) 1,1,5,1,3,5,3,5,3 (9th outcome) in this order.
12. this can be observed from the diagram, and the assumption that we can only walk one cell rightward or one cell downward is important