Group 2
Group 2
PROJECT - GROUP 2
TOPIC 2: BASIC COUNTING PRINCIPLES
HANOI - 2025
Contents
PREFACE 2
1
PREFACE
The basic counting principles play an important role in elementary combina-
torics and are widely applied in many problems in mathematics and real life. These
principles include the addition principle and the multiplication principle, which are
simple yet powerful tools to count the number of possible outcomes in a variety of
situations.
Although these principles are elementary, they form the foundation for more ad-
vanced methods in combinatorics and discrete mathematics. Through the use of
basic counting principles, one can solve problems involving arrangements, selec-
tions, and distributions efficiently and logically.
In mathematics education, especially for students with a strong interest in problem
solving and competitions, these principles are essential tools. They frequently appear
in school exams, contests, and also in real-world contexts such as scheduling, coding,
and data organization.
This report presents a clear explanation of the fundamental counting principles along
with several practical applications and examples. We hope that this document will
be useful for teachers, students, and anyone interested in learning or teaching basic
combinatorics.
We welcome any comments and suggestions to help improve the quality of this
material.
2
1 THE ADDITION AND MULTIPLICATION PRIN-
CIPLES
1.1 Theory
1.1.1 Addition Principle
N (A ∪ B) ≤ N (A) + N (B).
Hence, we have proved the lemma. Now apply it to two sets A1 and A2 :
3
A1 ∩ A3 = ∅
Thus we get A2 ∩ A3 = ∅
A1 ∩ A2 = ∅
Repeating the same argument, we obtain the desired result.
Example 1.2. There are two restaurants in our neighborhood, Pizza Shop and Soup
Kitchen. Pizza Shop has 10 different pizzas on its menu, and Soup Kitchen has 15
soups on its menu. The number of different options for lunch if we buy our lunch
from either of these restaurants is...
Solution
Solution
Because we have to choose from either a cupcake or donut or muffin (notice the
“OR”), we have 20 + 10 + 15 = 45 (treats) to choose from.
General principles.
If a task can be broken down into m consecutive steps.
For each of these, step 2 can be performed in n2 ways, and for each of these
step 3 can be performed in n3 ways,. . . And so on up to m.
Example 1.4. Let A and B be sets with m and n elements, respectively. Find the
number of functions from A to B.
Solution
4
f (a2 ): n choices,
..
.
f (am ): n choices.
Hence, by the multiplication principle, the number of functions from A to B is nm .
Example 1.5. A lottery ticket number is formed by two parts: the first part has 3
letters chosen from the 26-letter alphabet, and the second part has 4 digits chosen
from the decimal system. How many different tickets can be issued?
Solution
By the multiplication principle, the letter part has 263 possibilities.
Similarly, the number part has 104 possibilities.
Therefore, the total number of tickets is 263 · 104 .
5
1.2.2 Combination Formula
Definition 1.8. A combination is the choice of r things from a set of n things
without replacement. The order does not matter in combination. It may also be
the number of subsets with r elements from a set of n elements.
r n n!
Cn = = .
r (n − r)!.r!
Proof. We prove this formula based on Permutation Formula.
We adjust our permutation formula to reduce it by how many ways the objects
could be in order (because we aren’t interested in their order any more). There are
r objects, so the number of ways the objects could be in order equals the number of
permutations of r distinct objects.
Hence,
n n! 1 n!
= × = .
r (n − r)! r! r!(n − r)!
1.3 Exercises
Exercise 1: A class has 15 boys and 5 girls. All students are arranged in a straight
line for a group photo.
b) What is the probability that all boys stand together and all girls also stand
together?
Solution
20.19.18...2.1 = 20!
b) We have:
The number of ways to arrange 15 boys is 15!
The number of ways to arrange 5 girls is 5!
Case 1: The boys stands to the right of the girls.
Using Multiplication Principle, the number of ways to arrange 20 students is
15!.5!
6
Similarly with Case 2: The boys stands to the left of the girls.
Through both cases, using Addition Principle, the number of ways to arrange
20 students is 2.15!.5!
The probability that all boys stand together and all girls also stand together
2 · 15! · 5!
is:
20!
Exercise 2.1: Five men and nine women stand equally spaced around a circle in
random order. Find the number of arrangements of the above people.
Solution
Solution
7
First pin one man on one seat (to ensure no rotate situations). Then there are 13!
arrangements. (Exercise 2.1)
Therefore,
N (Ω) = 13!
Let A be the event: ”All people are arranged in a circle such that every man stands
diametrically opposite a woman.”
Remember that it has 5 men and 9 women. Therefore, there are 4 men left.
The first man has 12 ways to choose his position. (Because there are total 14
positions, we subtract the 2 positions of the man pinned and his partner.)
Similarly, the second man has 10 ways to choose his position. The third man has 8
ways to choose his position. And the last man has 6 ways to choose his position.
Hence the number of ways to arrange 5 men is 12.10.8.6.
There are a total of 9 women. Therefore, the number of ways to choose 5 women to
stand opposite the 5 men above is: A59
There are 4 women left. The number of ways to arrange them into the remaining 4
positions is: 4!
Hence
The answer is
48 + 143 = 191 .
Exercise 3.1: Determine the number of positive integer solutions of the equation
x1 + x2 + · · · + xm = n, n ∈ N
There are exactly n − 1 gaps between the candies. We place dividers in these gaps
to divide the candies into k parts.
8
We give the first part to the first child, the second part to the second child, and so
on, with the last part going to the kth child.
Clearly, the number of ways to distribute the candies is exactly the number of ways
to place the dividers as described above.
Choose k − 1 gaps among the n − 1 available gaps to place the dividers. There are
k−1
Cn−1 ways to do this. This is also the answer to the problem.
From this result, we can derive other equivalent formulations of the problem such
as Exercise 3.1.
Solution
Let xi represent the number of candies received by the ith child in the candy distri-
bution problem.
Then, the number of solutions to the equation is exactly the number of ways to
distribute n candies to m children.
m−1
Therefore, the number of positive integer solutions is Cn−1
Note: To find the number of non-negative integer solutions to the above equation,
we just need to add 1 to each term. Then, the problem will become Exercise 3.1.
x1 + x2 + · · · + xm = n
⇒ (x1 + 1) + (x2 + 1) + · · · + (xm + 1) = n + m
Exercise 3.2 (Hanoi Contest for Selecting the Team of Excellent Students,
2020–2021): Find the number of positive integer tuples (a1 , a2 , · · · , a15 ) that satisfy
the following conditions:
Solution
i 1 2 3 4 5 6 ... 14 15
ai ≡ i2 mod 5 1 4 4 1 0 1 ... 1 0
9
We put
a1 = 5k1 − 4
a2 − a1 = 5k2 − 2
a3 − a2 = 5k3
a4 − a3 = 5k4 − 3
a5 − a4 = 5k5 − 1
a6 − a5 = 5k6 − 4
..
.
a15 − a14 = 5k15 − 1
2020 − a15 = 5k16 − 5,
Remember that ki is positive integer. According to the result of Exercise 3.1, the
above equation has
m−1 15
Cn−1 = C410
sets of positive integer solutions.
10
2 THE INCLUSION-EXCLUSION PRINCIPLE
2.1 Theory
2.1.1 The Principle of Subtraction
N (A \ X) = N (A) − N (X).
This principle is often used with the philosophy: ”Count the easy part to deduce
the difficult part”. The following example illustrates this principle.
Example 2.1. Five people stand in a line. Calculate the probability that person A
does not stand next to person B.
Solution
There are 5! = 120 total arrangements. To count the number of arrangements where
A does not stand next to B, we first count the opposite case: A stands next to B.
Treat A and B as a single block. There are 4! ways to arrange this block with the
others. Since A and B can switch positions within the block, we have:
2 · 4! = 48.
5! − 2 · 4! = 72.
Solution
11
2.1.2 The Principle of Inclusion-Exclusion
Let A = A1 ∪ A2 ∪ . . . ∪ An , where A1 , A2 , . . . , An are finite sets. To find the number
of elements in set A, we proceed as follows.
First, for each fixed k such that 1 ≤ k ≤ n, consider the intersection of any k sets
among the initial n sets. Let Nk denote the total number of elements in all such
intersections.
Then we have:
n
X X
N1 = N (Ai ); N2 = N (Ai ∩ Aj );
i=1 1≤i<j≤n
X
Nk = N (Ai1 ∩ Ai2 ∩ . . . ∩ Aik );
1≤i1 <i2 <...<ik ≤n
Nn = N (A1 ∩ A2 ∩ . . . ∩ An ).
Lemma 2.4. n
X
N (A1 ∪ A2 ∪ . . . ∪ An ) = (−1)k−1 Nk . (1)
k=1
|X \ (A1 ∪ A2 ∪ · · · ∪ An )| = N − |A1 ∪ A2 ∪ · · · ∪ An |.
Using the inclusion-exclusion principle, we have:
|X \ (A1 ∪ A2 ∪ · · · ∪ An )| = N − N1 + N2 − N3 + · · · + (−1)n Nn
12
where Nk denotes the sum of the cardinalities of all k-fold intersections of the sets
Ai .
This formula is known as the Inclusion-Exclusion Principle, a powerful tool in
combinatorics.
Example 2.5. There are n letters and n envelopes, each labeled with an address.
The letters are randomly placed into the envelopes.
(a) What is the probability that no letter ends up in the correct envelope?
(b) What is the probability that exactly k letters (with 0 ≤ k ≤ n) end up in the
correct envelopes?
Solution
(a) The total number of ways to assign the letters into envelopes is n!.
Let X be the set of all such permutations.
Let Ak be the set of permutations where the k-th letter is placed in the correct
envelope.
Then we have n subsets: A1 , A2 , . . . , An . To count the number of derangements
(i.e., permutations with no fixed points), we apply the inclusion-exclusion prin-
ciple.
Note that:
|Ai1 ∩ Ai2 ∩ · · · ∩ Aik | = (n − k)!
because we fix k positions and permute the remaining n − k letters.
There are nk such intersections, so:
n n!
Nk = (n − k)! =
k k!
(b) We want the probability that exactly k letters are in the correct envelopes.
The number of derangements of n − k elements is:
n−k
X (−1)j
Dn−k = (n − k)!
j=0
j!
13
Thus, the number of favorable permutations is:
n−k
(−1)j
n n X
· Dn−k = (n − k)!
k k j=0
j!
2.2 Exercises
Exercise 1: Determine the number of surjections (onto functions) from a set A
with m elements to a set B with n elements.
Solution
and X
Nk = N (Ai1 ∩ Ai2 ∩ ... ∩ Aik )
1≤i1 <i2 <...<ik ≤n
We see that N (Ai1 ∩ Ai2 ∩ ... ∩ Aik ) is the number of functions from A to the set of
(n − k) elements .
Definition 2.6. A Stirling number of the second kind, denoted by S(n, k), is the
number of ways to partition a set of n labeled objects into k nonempty unlabeled
subsets.
14
By applying the result of Exercise 1, we obtain:
k
1 X
S(n, k) = (−1)i Cki (k − i)n
k! i=0
Solution
Let X = {1, 2, . . . , m} and let Ai be the set of numbers in X that are divisible by
ai . Then we obtain A1 , A2 , . . . , An as subsets of X.
It is clear that the number of desired numbers is
N = N [X \ (A1 ∪ A2 ∪ . . . ∪ An )]
and N = N (X) = m.
We have:
X
Nk = N (Ai1 ∩ Ai2 ∩ . . . ∩ Aik )
1≤i1 <i2 <...<ik ≤n
where
N (Ai1 ∩ Ai2 ∩ . . . ∩ Aik ) = the number of elements in X hdivisiblei by ai1 , . . . , aik
= the number of elements in X divisible by ai1 . . . aik = ai m ...aik
1
Thus,
X m
Nk =
1≤i <i <...<i ≤n
ai1 . . . aik
1 2 k
Therefore,
n
X
k−1
X m
N =m− (−1)
k=1 1≤i1 <i2 <...<ik ≤n
ai1 . . . aik
n
X
k
X m
=m+ (−1)
k=1 1≤i <i <...<i ≤n
ai1 . . . aik
1 2 k
Exercise 3: (Euler’s formula) For every integer n > 1, let φ(n) denote the number
of positive integers less than n that are coprime to n. Prove that
m
Y 1
φ(n) = n (1 − )
i=1
pi
Solution
15
Let S be the set of the first n positive integers and let Ai be the subset of S consisting
of numbers divisible by pi , where i = 1, 2, . . . , m.
Then, the set S \ (A1 ∪ A2 ∪ . . . ∪ Am ) consists of the positive integers less than n
that are coprime to n.
For 1 ≤ i1 < . . . < ik ≤ m, we have:
h i
n
N (Ai1 ∩ Ai2 ∩ . . . ∩ Aik ) = pi ...p i
= pi pin...pi
1 k 1 2 k
and
X
Nk = N (Ai1 ∩ Ai2 ∩ . . . ∩ Aik )
1≤i1 <i2 <...<ik ≤m
φ(n) = N [S \ (A1 ∪ A2 ∪ . . . ∪ Am )]
= N (S) − N (A1 ∪ . . . ∪ Am )
Xm
=n− (−1)k−1 Nk
k=1
m
X n X n n
=n− + − . . . + (−1)m
i=1
pi 1≤i<j≤m pi pj p 1 . . . pm
m
!
X 1 X 1 1
=n 1− + − . . . + (−1)m
p
i=1 i
pp
1≤i<j≤m i j
p 1 . . . pm
m
Y 1
=n 1−
i=1
pi
Exercise 4: Given a determinant of order n, where all the elements on the main
diagonal are zero and the other elements are nonzero real numbers. How many terms
in this determinant are equal to 0?
Recall
X n
Y
det(A) = sign(σ) aiσ(i)
σ∈Sn i=1
Solution
16
Thus, the number of satisfied permutations is
n
X n
X
(−1)k−1 Nk = (−1)k−1 Cnk (n − k)!
k=1 k=1
n
X n!
= (−1)k−1
k=1
k!
n
X (−1)k−1
= n!
k=1
k!
Exercise 5: A box contains 5 distinct red marbles, 4 distinct yellow marbles and 9
distinct blue marbles. How many ways are there to choose 6 marbles such that all
three colors are represented?
Solution
N (X) = C18
6
N (A) = C13
6 6
, N (B) = C14 , N (C) = C96
N (A ∩ B) = C96 , N (B ∩ C) = 0, N (A ∩ C) = 0
N (A ∩ B ∩ C) = 0
6 6 6
⇒ N [X \ (A ∪ B ∪ C)] = C18 − C13 − C14 − C96 + C96 + 0 + 0 − 0 = 13845
Therefore, there are 13845 ways to choose 6 marbles such that all three colors are
represented.
Exercise 6: Find the number of non-negative integer roots of the equation:
x1 + x2 + x3 + x4 = 15
such that
x1 ≤ 3, x2 ≤ 4, x3 ≤ 5, x4 ≤ 7.
Solution
17
Let U be the set of all non-negative integer roots of the equation
x1 + x2 + x3 + x4 = 15
We recall the Euler’s candy division problem: How many ways to distribute n
identical candies to m children such that each child has at least one candy?
Equivalently, we need to find the number of positive integer roots of the equation
x1 + x2 + ... + xm = n(n ≥ m ≥ 1)
and X
Nk = N (Ai1 ∩ Ai2 ∩ ... ∩ Aik )
1≤i1 <i2 <...<ik ≤4
N (A1 ) = C14
3 3
= 364, N (A2 ) = C13 3
= 286, N (A3 ) = C12 3
= 220, N (A4 ) = C10 =
120 ⇒ N1 = 990.
N (A1 ∩A2 ) = C93 = 84, N (A1 ∩A3 ) = C83 = 56, N (A1 ∩A4 ) = C63 = 20, N (A2 ∩
A3 ) = C73 = 35, N (A2 ∩ A4 ) = C53 = 10, N (A3 ∩ A4 ) = C43 = 4 ⇒ N2 = 209.
N4 = N (A1 ∩ A2 ∩ A3 ∩ A4 ) = 0.
18
a) In each number, each digit appears exactly two times?
b) In each number, two identical digits are not next to each other?
Solution
and X
Nk = N (Ai1 ∩ Ai2 ∩ ... ∩ Aik )
1≤i1 <i2 <...<ik ≤5
We have:
10!
N (A) = = 113400
25
For each number in Ai , consider 2 adjacent digits i as 1 digit.
This means that N (Ai ) is the number of ways we arrange 9 digits where there are
4 digits appearing two times.
9! 9!
⇒ N (Ai ) = ⇒ N1 = 5 · = 113400
24 24
Using the above argument, we can generalize that:
(10 − k)!
Nk = C5k · , ∀k = 1, 5.
25−k
⇒ N2 = 50400, N3 = 12600, N4 = 1800, N5 = 120.
⇒ N = 113400 − 1133400 + 50400 − 12600 + 1800 − 120 = 39480 .
Exercise 8: How many ways are there to arrange 8 rooks on an international
chessboard with a main diagonal crossed out so that no rook can attack another?
Solution
19
We will count the number of arrangements so that there is at least 1 rook on the
diagonal.
Let Ai be the set of arrangements such that the rooks are placed on the square (i, i),
for i = 1, 8.
We need to determine N (A1 ∪ A2 ∪ ... ∪ A8 ).
We see that N (Ai ) is the number of arrangements for 7 rooks that are not in the
i-th row and column.
Thus, N (Ai ) = 7!, ∀i = 1, 8.
Similarly, N (Ai ∩ Aj ) = 6!, N (Ai ∩ Aj ∩ Ak ) = 5!, ..., N (A1 ∩ A2 ∩ ... ∩ A8 ) = 1!.
Then, according to the inclusion-exclusion principle, the number of satisfied
arrangements is
8
X X
N = N (U ) − N (Ai ) + N (Ai ∩ Aj ) − ... + N (A1 ∩ A2 ∩ ... ∩ A8 )
i=1 1≤i̸=j≤8
⇒ N = 8! − C81 .7! + C82 .6! − C83 .5! + C84 .4! − C85 .3! + C86 .2! − C87 .1! + C88 .0! = 14833
The End
20