0% found this document useful (0 votes)
7 views35 pages

CCT 103 Notes

The document provides notes on basic counting techniques in discrete structures, covering principles such as the Product Rule, Sum Rule, Subtraction Rule, and Division Rule. It includes examples illustrating how to apply these rules to solve counting problems in mathematics and computer science. Additionally, it introduces permutations and combinations, explaining how to count ordered and unordered selections of objects.

Uploaded by

Mike chiti
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views35 pages

CCT 103 Notes

The document provides notes on basic counting techniques in discrete structures, covering principles such as the Product Rule, Sum Rule, Subtraction Rule, and Division Rule. It includes examples illustrating how to apply these rules to solve counting problems in mathematics and computer science. Additionally, it introduces permutations and combinations, explaining how to count ordered and unordered selections of objects.

Uploaded by

Mike chiti
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 35

DISCRETE STRUCTURES I (CCT 103) NOTES

BY

MR. OLOO ALBERT

MASENO UNIVERSITY

c 2021
CHAPTER 1

BASIC COUNTING TECHNIQUES

Counting problems arise throughout mathematics and computer science. For ex-
ample, we must count the successful outcomes of experiments and all possible
outcomes of the experiments to determine possibilities of discrete events. We
need to count the number of operations used by an algorithm to study its time
complexity. In this chapter, we introduce basic techniques of counting which
serve as the foundation for almost all counting techniques. We begin with dis-
cussing two counting principles

1.1 Product Rule

Suppose that a procedure can be broken into a sequence of two tasks. If there are
n1 ways of doing the first task and each of these ways of doing the first task, there
are n2 ways to do the second task, then there are n1 n2 ways to do the procedure.

Example 1.1.1. A new company with two employees John and Fidel rents a floor
of a building with 12 offices. How many ways are there to assign different offices
to those two employees?
Solution
The procedure of assigning offices to these two employees consist of assigning
an office to John, which can be done in 12 ways, then assigning and office to

1
Fidel different from the office assigned to John. This can be done in 11 ways.
By product rule, there are 12 · 11 = 132 ways to assign the offices to the two
employees.

Example 1.1.2. There are 32 microcomputers in a computer lab. Each microcom-


puter has 24 ports. How many different ports a microcomputer in the lab are
there?
Solution
The procedure of choosing a port consist of two tasks, first picking a microcom-
puter and then picking a port, on this microcomputer. There are 32 ways to
choose a microcomputer and 24 ways to choose a port on a microcomputer there-
fore by product rule, there are 32 · 24 = 768 ports.

Remark 1.1.3. Suppose that a procedure carried out by performing the tasks
T1 , T2 · · · , Tn in sequence. If each task Ti , for i = 1, 2, · · · , n can be done in ni
ways regardless of how the previous tasks were done, then there are ni · n2 · · · nm
ways to carry out the procedure.

Example 1.1.4. How many different bit strings of length seven are there?
Solution
Each of the seven bit strings can be chosen in two ways because each bit is either
0 or 1. Therefore the product rule shows that there are 27 = 128 different bit
strings of length seven.

Example 1.1.5. What are the possible outcomes in a football competition with 17
matches?
Solution
Each football match has three possible outcomes, therefore for the 17 matches
there are 317 possible outcomes.

Example 1.1.6. How many different license plates can be made if each plate con-
tains a sequence of 3 upper case English letters followed by 3 digits (no sequence
of letters are prohibited even if they are obscene).
Solution

2
There are 26 choices for each of the three upper case alphabets and 10 possible
choices for each of the three digits. By product rule we have (26 · 26 · 26 · 10 · 10 ·
10) = 17, 576, 600 possible license plates.

Example 1.1.7. How many functions are there from a set with m elements to a
set with n elements?
Solution
A function corresponds to a choice of one of the n elements in the codomain
for each of the m elements in the domain. Hence by product rule n · n · · · nm
functions from a set of m elements to a set of n elements. For instance, there
are 53 = 125 different functions from a set with three elements to a set with five
elements.

Example 1.1.8. How many one-to-one functions from a set with m elements to
one with n elements?
Solution
Note when m > n there are no one-to-one functions from set of m elements to
a set of n elements. Now, let m ≤ n suppose the elements in the domain are
a1 , a2 , · · · am . There are n ways to choose the value of the function at a1 because
the function is one-to-one, the value of a2 can be picked in n − 1 ways (because
the value for a1 cannot be used again). Generally, the value of a function at ak can
be chosen in n − k + 1 ways. By product rule, there are n(n − 1)(n − 2) · · · (n −
m + 1) one-to-one functions from a set of m elements to a set of n elements. For
instance, there are 5 · 4 · 3 = 60 one-to-one functions from a set of 33 elements to
a set of 5 elements.

1.2 Sum Rule

If a task can be done either in one of n1 ways or one of n2 ways, where none of
the set of n1 ways is the same as any of the set of n2 ways, then there are n1 + n2
ways to do the task.

3
Example 1.2.1. Suppose that either a member of the mathematics faculty or a
student who is major mathematics is chosen as a representative to a university
committee. How many different choices are there for this representative if there
are 37 members of the mathematics faculty and 83 major mathematics students.
No one in the committee is both faculty member and student.
Solution
There are 37 ways to choose from the members of the faculty and 83 ways to
choose from the students. Choosing someone from the faculty is not the same
as choosing a student since no member is from both categories. By sum rule it
follows that there are 37 + 83 = 120 possible ways to pick the representatives.

Remark 1.2.2. We can also use sum rule for more than two tasks i.e suppose that
a task can be done in one of the n1 ways, in one of the n2 ways,· · · , or in one of
the nm ways, where non of the set of ni ways of doing the tasks is the same as
any of the set of n j ways for all pairs i and j with 1 ≤ i < j ≤ m.Then the number
of ways to do the task is n1 + n2 + · · · nm .

Example 1.2.3. A student can choose a computer project from one of three lists.
The three list contain 23, 15 and 19 possible projects respectively. No project is
on more than one list. How many possible projects are there to choose from?
Solution
The student can choose by selecting a project from the first, second or third list.
Because no project is in more than one list, then by sum rule , there re 23 + 15 +
19 = 57 way to choose a project.

1.3 Subtraction Rule

Suppose that a task can be done in one of the two ways, but some of the ways to
do it are common to both ways. In this situation, we cannot use the sum rule to
count the number of ways to do the task. If we add the number of ways to do
the task in the ways we get an over count of the total number of ways to do it,
because the ways to do the task that are common to the two ways are counted

4
twice. To correctly count the number of ways to do the tasks, we must subtract
the number of ways that are counted twice. This leads to the subtraction rule:
It a task can be done in either n1 ways or n2 ways then, the number of ways to
do the task is n1 + n2 minus the number of ways to do the task that are common
to the different ways.
The subtraction rule is also known as principle of inclusion-exclusion.
For instance, there are | A1 | ways to select elements from set A1 and | A2 | ways to
select elements from set A2 . Therefore the number of ways to select an element
from set A1 or A2 is simply the number of ways to choose an element from the
union of set A1 or A2 minus the number of ways to select elements in both A1
and A2 .
| A1 ∪ A2 | = | A1 + | A2 | − | A1 ∩ A2 |

Example 1.3.1. How many bit strings of length eight either start with 1 bit or end
with the two bits 00?
Solution
We can construct abit string with length 8 which either begins with 1 or ends with
00. To construct a bit string of length 8 beginning with 1 bit there are 27 = 128
ways. This follows by product rule since the first bit can be chosen only in one
way and the rest can be chose in 7 ways. Similarly we can construct a bit string
of length 8 ending with 00 in 26 = 64 ways. This follows by product rule since
each of the first six bit bits can be chosen in one way and the last two bits can be
chosen in one way. Some of the ways to construct a bit string of length 8 starting
with 1 are same as ways to construct such a string ending with 00. So there are
25 = 32 ways to construct such strings. This follow by product rule since the first
bit can be chosen only in one way then from second to sixth bit can be chosen in
one way. Therefore the number of ways to construct a bit string of length eight
that begins with 1 or ends with 00 is

128 + 64 − 32 = 160

5
Problem 1.3.2. A computer company receives 350 applications from computer
graduates for a job planning a line of web servers. Suppose 220 of these appli-
cants major computer science, 147 major business and 51 major both computer
and business. How many of these application majored neither in computer sci-
ence nor in business.

1.4 Division Rule

n
There are d ways to do a task if it can be done using procedure that can be carried
out in n ways and for every way w, exactly d of the n ways correspond to way w.

Example 1.4.1. How many different ways are there to seat four people around a
circular table where two seatings are considered the same when each person has
the same left neighbour and the same right neighbour?
Solution
We arbitrarily select a seat at the table and label it seat 1. We number the rest of
the seats in a numerical order proceeding clockwise around the table. There are
four ways to select the person for seat 1. three ways to select a person for seat
2, two ways to select a person for seat 3 and one way for seat 4. Thus 4! = 24
ways to order the given four people for the seats. Because there are four ways to
24
choose the person for seat 1, by division rule, there are 4 = 6 different seating
arrangements of four people around a circular table.

1.5 Permutations and Combinations

1.5.1 Introduction

Many counting problems can be solved by finding the number of ways to arrange
a specified number of distinct elements of a set where the order of these elements
matter and in another instance when the order does not matter.

6
In this section we develop methods to answer such questions.

1.6 Permutations

A permutation of a set of distinct object is an ordered arrangement of these ob-


jects

Example 1.6.1. In how many ways can we select three students from a group of
five students to standing in line for a picture? In how many ways can we arrange
all the five students for a picture?
Solution

1. First we note that the order of selecting the three students matter, there are
5 ways to choose the first student, 4 way to choose the secod student, 3
ways to choose the third student. So, by product rule, we have 5 · 4 · 3 = 60
ways. Simply written as 5P3 = 60.

2. To arrange the five students in a line, the order matters so the first student
can be selected in 5 ways, the second student in 4 ways, the third student
in 3 ways, the fourth student in 2 ways and the fifth student in 1 way so we
have 5 · 4 · 3 · 2 · 1 = 120 or simply 5! = 120.

Example 1.6.2. Let S = {1, 2, 3} the ordered arrangement 3, 1, 2 is a permutation


of S. The ordered arrangement 3, 2 is a 2- permutation of S. The number of r-
permutation of a set with n elements is denoted by P(n, r ). We find P(n, r ) using
product rule.

Example 1.6.3. Find the 2-permutation of a set S = { a, b, c}. hence list the per-
mutations.
Solution We note that the set has 3 elements and we need 2- permutation. So, we
have P(3, 2). This is written as 3P2 = 6. the permutations are { a, b},{ a, c},{b, a},{b, c},{c, a}
and {c, b}.

7
Theorem 1.6.4. If n is positive integer and r is an integer with 1 ≤ r ≤ n then there
are P(n, r ) = n(n − 1)(n − 2) · · · (n − r + 1) r- permutation of a set with n distinct
elements.

Proof. The first element of the permutation can be chosen in n ways, since there
are n elements in the set. There are n − 1 ways to choose the second element
because there are n − 1 elements left in the set after using the element picked for
first position. Similarly, there are n − 2 ways to choose the third element and so
on, until there are exactly n − (r − 1) = n − r + 1 ways to choose the r th element
consequently using product ruel, we have n(n − 1)(n − 2) · · · (n − r + 1)

NOTE that P(n, 0) = 1 where n is a nonnegative integer because there is exactly


one way to order zero elements i.e exactly one list with no element in it, namely
the empty set.

Corollary 1.6.5. If n and r are integers with 0 ≤ r ≤ n, then

n!
P(n, r ) =
(n − r )!

Example 1.6.6. How many ways are there to select first-prize winner, second-
prize winner and third-prize winner from 100 different people who have entered
a contest?
n! 100!
Solution P(100, 3) = ( n −r ) !
= (100−3)!
= 99 · 98 · 97 = 970, 200

Example 1.6.7. How many different ways are there to award Gold, Silver and
Bronze medals to first, second and third winners respectively in an athletics com-
petition consisting f 8 athletes if all possible outcomes of the race occur and there
are no ties?
Solution

n! 8!
P(8, 3) = ( n −r ) !
= (8−3) !
= 336

Problem 1.6.8. ;

8
1. Suppose that a sales lady has to visit eight different cities, she must begin
her trip in a specified city, but she can visit the other seven cities in any
order she wishes. How many possible orders can the lady use to visit these
cities

2. How many permutations of the elements ABCDEFGH contain ABC?

1.7 Combinations

We now turn our focus to counting unordered selection of objects

Example 1.7.1. How many different committees of three students can be formed
from a group of four student?
Solution
Here we only need to find the number of subsets with three elements from a set
of four students. It is clear that by forming a committee of three is like removing
each student from the group at a time. So there are four ways to choose the three
student, where the order does not matter.

Remark 1.7.2. An r- combination of elements of a set is an ordered selection of r


elements from the set. Thus r- combination is simply a subset with r elements

Example 1.7.3. Let S = {1, 2, 3, 4}. Then {1, 3, 4} is a 3- combination from S.


The r- combination of a set with n distinct elements is denoted by C (n, r ). note
that C (n, r ) is also denoted by (nr) called binomial coefficient.

Example 1.7.4. Obtain the 2- combinations of a set { a, b, c, d}


Solution
C (4, 2) = (42) = 6 there are six such combinations that is { a, c}, { a, b}, { a, d}, {b, c}, {b, d}, {c, d}.

Theorem 1.7.5. The number of r-combinations of a set with n elements where n is a


nonnegative integer and r is an integer with 0 ≤ r ≤ n equals
n!
C (n, r ) =
r!(n − r )!

9
Proof. The P(n, r ) r- permutations of the set can be obtained by forming the
C (n, r ) r- combinations of the set and then ordering the elements in each r- com-
bination, which can be done in P(r, r ) ways. Consequently by product rule
P(n,r ) n!/(n−r )! n!
C (n, r ) = P(r,r )
= r!/(r −r )!
= r!(n−r )!

Example 1.7.6. How many pokers hand of five cards can be dealt from a standard
deck of 52 cards?
Solution
52!
C (52, 5) = 5!47! = 2, 598, 960

Corollary 1.7.7. Let n and r be nonnegative integers with r ≤ n. Then C (n, r ) =


C (n, n − r )

Example 1.7.8. How many ways are there to select five players from 10 members
tennis team to make a trip to a match at another school?
Solution
10!
C (10, 5) = 5!5! = 252

Problem 1.7.9. ;

1. How many ways are there to select a crew of 6 people from a group of 30
trained Astronauts?

2. Suppose that there are 9 faculty members in maths department and 11 in


computer science department. How many ways are there to select a com-
mittee to develop discrete maths course at a school if the committee is to
consist of 3 faculty members from maths department and 4 from computer
department?

1.8 Binomial Coefficients and Identities

The number of r- combinations from a set of n elements is often denoted by


(nr). This number is called binomial coefficient because these numbers occur as
coefficients in the expansion of powers of binomial expression such as ( a + b)n .

10
1.8.1 Binomial Theorem

The binomial theorem gives the coefficient of the expression of powers of bino-
mial expressions. A binomial expression is simply the sum of two terms such as
( x + y)

Example 1.8.1. When the expression ( x + y)3 = ( x + y)( x + y)( x + y) is ex-


panded, all the products of a term in the first sum, a term in the second sum
and a term in the third sum are added. terms of x3 , x2 y, xy2 , and y3 arise. To
obtain x3 , an x must be chosen from each sum and this can be done ones hence
x3 has a coefficient of 1. To obtain x2 y, an x must be chosen in two of the three
sums and consequently a y in the other sum.Hence the number of such terms is
the number of 2- combinations of three objects namely (32). Similarly, the number
of terms of the form xy2 is the number of ways to pick one of the three sums to
obtain x consequently take a y from each of the other two sums this can be done
in (31). Finally the only way to obtain y3 term is to choose y from each of the three
sums and it can be done exactly ones. Consequently it follows that
( x + y)3 = ( x + y)( x + y)( x + y)
=( xx + xy + yx + yy)( x + y)
=xxx + xxy + xyx + xyy + yxx + yxy + yyx + yyy
=x3 + 3x2 y + 3xy2 + y3

Theorem 1.8.2. Binomial theorem Let x and y be variable and let n be a nonnegative
integer then
n         
n n− j j n n n n −1 n n n
( x + y) = ∑
n
x y = x + x y+···+ xy n −1
+ y
j =0
j 0 1 n−1 n

Example 1.8.3. What is the expansion of ( x + y)4


Solution
From binomial theorem,
( x + y)4 = ∑4j=0 (4j ) x4− j y j
=(40) x4 + (41) x3 y + (42) x2 y2 + (43) xy3 + (44)y4
=x4 + 4x3 y + 6x2 y2 + 4xy3 + y4

11
Example 1.8.4. What is the coefficient of x12 y13 in the expression ( x + y)25 ?
Solution
From binomial theorem it follows that the coefficient is
 
25 25!
= = 5, 200, 300
13 13!12!

Example 1.8.5. What is the coefficient of x12 y13 in the expression (2x − 3y)25 ?
Solution
Note that (2x − 3y)25 =(2x + (−3y))25
From binomial theorem
25 25− j (−3y ) j
(2x + (−3y))25 =∑25
j=0 ( j )(2x )

So the coefficient of x12 y13 is obtained when j = 13 so we have


(25 12 13 25! 12
13)(2) (−3) = − 13!12! · 2 · 3
13

Corollary 1.8.6. Let n be a nonnegative integer. Then ∑nk=0 (nk) = 2n

Proof. Using binomial theorem, when x = 1 and y = 1 we see that


( x + y)n = (1 + 1)n = 2n = ∑nk=0 (nk)1k 1n−k = ∑nk=0 (nk)

We can also give a combinatorial proof of the corollary as shown

Proof. A set with n elements has a total of 2n different subsets. Each subset has
zero elements. One element, two elements,· · · or n elements in it. There are
(n0 ) subsets with zero elements (n1 ) subsets with one element, (n2 ) subsets with
2 elements,· · · , (nn) subsets with n elements therefore, ∑nk=0 (nk) counts the total
number of subsets of a set with n elements. By equating the two formulas, we
have for the number of subsets of a set with n elements we see that ∑nk=0 (nk) =
2n .

Corollary 1.8.7. Let n be a positive integer. Then, ∑nk=0 (−1)k (nk) = 0

Proof. When we use the binomial theorem with x = 1 and y = −1, we see that
0 = 0n = (1 + (−1))n = ∑nk=0 (nk)(1)n−k (−1)k = ∑nk=0 (nk)(−1)k

12
Remark 1.8.8. Corollary(4.1.23) implies that
(n0 ) + (n2 ) + (n4 ) + · · · = (n1 ) + (n3 ) + (n5 ) + · · ·

Corollary 1.8.9. Let n be a nonnegative integer then ∑nk=0 2k (nk) = 3n

Proof. We see that the LHS of this formula is expansion of (1 + 2)n provided by
the binomial theorem. Therefore by binomial theorem, we see that
(1 + 2)n = ∑nk=0 (nk)1n−k 2k = ∑nk=0 (nk)2k hence
n
∑nk=0 ( k )2k = (1 + 2)n = 3n

1.8.2 Pascal’s Identity

Let n and k be positive integers with n ≥ k. then (n+ 1 n n


k ) = ( k −1 ) + ( k ).

Proof. We use combinatorial proof. Suppose that T is a set containing n + 1 ele-


ments. Let a be an element in T, and let S = T − { a}. note that there are (n+ 1
k )
subsets of T containing k elements however, a subset of T with k elements either
contains a together with k − 1 elements of S or contains k elements of S and does
n
not contain a. Because there are (k− 1) subsets of k − 1 elements of S, there are
(k−n 1) subsets of k elements of T that contain a and there are (nk) subsets of k ele-
ments of T that do not contain a, because there are (nk) subsets of k elements of S.
Consequently,      
n+1 n n
= + .
k k−1 k

Theorem 1.8.10. Vandermonde’s Identity Let m,n and r be nonnegative integers


with r not exceeding either m or n. Then,
  r   
m+n m n
= ∑
r k =0
r−k k

Proof. Suppose that that there are m items in one set and n items in a second
set. Then the total number of ways to pick r elements from the union of the

13
two sets is (m+ n
r ). Another way to pick r elements from the union is to pick
k elements from the second set and r − k from the first set where 0 ≤ k ≤ r.
because there are (nk) ways to choose elements from a second set and (r−
m
k ) ways
to choose elements from the first set , the product rule tell us that this can be
m n
done in (r− k )( k ) ways. Hence the total number of ways to pick r elements from
m n
the union is also ∑rk=0 (r− k )( k ). We have found two expressions for the number
of ways to pick r elements from the union of a set with m items and a set with n
items. Equating The gives us the Vandermonde’s identity.

n 2
Corollary 1.8.11. If n is a nonnegative integer then (2n n
n ) = ∑ k =0 ( k )

Proof. We use Vandermonde’s identity with m = r = n to obtain


n n n 2
(2n n n
n ) = ∑k=0 (n−k )( k ) = ∑k=0 ( k )
n
Note: (nk) = (n− k)

1.8.3 Multinomial coefficients

Suppose you have n objects to be coloured red and blue. If k are coloured red
then n − k are coloured blue: (nk) or (nk)(nn− k
− k ).
When we have three objects to be coloured red, blue and green. If k1 are coloured
red, Then k2 = n − k1 are coloured blue and k3 = n − k1 − k2 are coloured green.
So we have
(kn1 )(n−k2k1 )(n−kk13−k2 )
=(kn1 )(n− k1 n−k1 −k2
k )(n−k −k )
2 1 2

=(kn1 )(n− k1
k2 )
= k!(nn! · (n−k1 )!
−k1 )! k2 !(n−k1 −k2 )!
= n!
k! · 1
k2 !(n−k1 −k2 )!
= n!
k1 !k2 !k3 !
=(k1 kn2 k3 )

Example 1.8.12. What is the coefficient of x99 y60 z14 in (2x3 + y − z2 )100
Solution
(2x3 + y − z2 )100 = ∑k1 +k2 +k3 =100 (k1100 3 k1 k2
k2 k3 )(2x ) y (− z )
k3

=(k1100 k1 3 k1 k2 k3
k2 k3 )2 ( x ) y (−1) ( z )
k3

14
Solving for k1 , k2 and k3 we obtain k1 = 33, k2 = 60 and k3 = 7
So the required coefficient is
100 100
(33,60,7 )233 (−1)7 = −(33,60,7 )233

1.9 Floor and Ceiling functions

Floor and ceiling functions give the nearest integer up and down. For instance
consider 2.31
Floor of 2.31 = 2 and Ceiling of 2.31 = 3. The floor and the ceiling of a number
which is already an integer remain the same integer e.g The floor and ceiling of
5 is simply 5.

Symbols

The floor of X is written as b X c


The ceiling of X is written as d X e

Definition 1.9.1. Floor function - The greatest integer that is less than or equal to
x

Definition 1.9.2. Ceiling function- The least integer that is greater than or equal to
x.

Example 1.9.3. What is the floor and ceiling of 3.32?


Solution
Note that the floor of 3.32 can be 3 or 2 or 1 or · · · but the greatest of all the
possible floors is 3 so b3.32c = 3
The ceiling of 3.32 can be 4 or 5, or · · · but the least of the possible ceilings is 4 so
d3.32e = 4.

15
The ”frac” function

With the floor function we ”throw away” the fractional part. This part is called
fractional part or simply ”frac”.
frac ( x )=x − b x c

Example 1.9.4. Find the frac3.65


frac(3.65)=3.65 − 3 = 0.65.

Example 1.9.5. What is the frac−3.65


frac(−3.65)= −3.65 − (−4) = 0.35

1.10 The Pigeonhole Principle

Suppose that a flock of 20 Pigeons flies into a set of 19 Pigeonholes to roost.


because there are 20 Pigeons but only 19 holes, then atleast one of the holes must
have atleast two Pigeons in it. The Pigeonhole Principle states that:
If k is a positive integer and k + 1 or more objects are placed into k boxes , then
there is atleast one box containing two or more of the objects.

Proof. We prove the Pigeonhole principle using proof by contraposition. Sup-


pose that none of the k boxes contain more than one object. Then the total num-
ber of objects would be at most k. This is a contradiction because there are atleast
k + 1 objects.

Corollary 1.10.1. A function from a set with k + 1 or more elements to a set with k
elements is not one-to-one.

Proof. Suppose that for each element y in the codomain of f we have a box that
contains all elements x of the domain of f such that f ( x ) = y. Because the
domain contains k + 1 or more elements and codomain contains only k elements
, the Pigeonhole principle tells us that one of these boxes contains two or more
elements x of the domain. This means that f cannot be one-to-one.

16
Example 1.10.2. ;

1. Among any group of 367 people there must be atleast two with same birth-
day, because there are only 366 possible birthdays.

2. In any group of 27 English words, there must atleast two or more beginning
with the letter,because there are only 26 letters in English alphabet.

1.10.1 Generalized Pigeonhole Principle

The Pigeonhole principle states that there must be atleast two objects in the same
box when there are more objects than the boxes.

Theorem 1.10.3. If N objects are placed into k boxes, then there is atleast one box con-
taining atleast d Nk e objects.

Proof. We will use proof by contraposition. Suppose that none of the boxes con-
tain more than d Nk e − 1 objects. Then the total number of objects is atmost
    
N N
k d e−1 < k + 1 − 1 = N,
k k

where the inequality d Nk e = Nk + 1 has been used. This is a contradiction




because there are a total of N objects.

Example 1.10.4. ;

1. Among 100 people there are atleast d 100


12 e = 9 who were born in the same
month.

2. What is the minimum number of students required in a discrete mathemat-


ics class to be sure that atleast six will receive the same grade, if there are
five possible grades A,B,C,D and F.
Solution

17
The minimum number of students required to be sure that atleast six re-
ceive same grade is the smallest integer N such that d N5 e = 6. The smallest
such integer is N = 5 · 5 + 1 = 26. if you have 25 students then it is possi-
ble that for there to be five students who receive each grade so that no six
students receive same grade. Thus 26 is the minimum number of students
needed to ensure that atleast six students receive same grade.

Problem 1.10.5. ;

1. How many cards must be selected fro, a standard deck of 52 cards to guar-
antee that atleast three cards of the same suit are chosen?

2. During a month with 30 days, a baseball team plays atleast one game a
day, but no more than 45games. Show that there must be a period of some
number of consecutive days during which the team plays exactly 14 games.

3. Show that among any n + 1 positive integers not exceeding 2n, there must
be be an integer that divides one of the other integers.

4. Assume that in a group of six people, each pair of individuals consist of two
friends or two enemies. Show that there are either three mutual friends or
three mutual enemies in the group.

18
CHAPTER 2

ELEMENTARY NUMBER THEORY

2.0.1 Divisibility and modular arithmetic

The ideas we will develop in this section are based on the notation of divisibility.
Division of an integer by a positive integer produces a quotient and a remain-
der. Working with these remainders leads to modular arithmetic which plays an
important role in mathematics and is also used in computer science.

Division

When one integer is divided by a second non-zero integer, the quotient may or
may not be an integer e.g 12
4 = 4 is an integer whereas
11
4 = 2.75 is not an integer.

Definition 2.0.1. If a and b are integers with a 6= 0, we say that a divides b if there
b
is an integer c such that b = ac or equivalently, if a is an integer. When a divides
b we say a is a factor r divisor of b, and that b is a multiple of a. The notation a|b
denotes a divides b. We write a - b when a does not divide b.

Example 2.0.2. ; Determine whether 3|7 and whether 3|12.


Solution
7
We see that 3| 7 because 3 is not an integer. On the other hand 3|12 = 4

Example 2.0.3. : Let n and d be positive integers . How many positive integers

19
not exceeding n are divisible by d
Solution
All the positive integers divisible by d are of the form dk, where K is a positive
integer. Hence the number of positive integers divisible by d not exceeding n
equals to the number of integers k with 0 < dk ≤ n or with 0 < k ≤ nd . Therefore
there are b nd c positive integer not exceeding n that are divisible by d

Theorem 2.0.4. Let a, b and c be integers, where a 6= 0. Then

1. If a|b and a|c then a|(b + c)

2. If a|b then a|bc for all integer c

3. If a|b and b|c then a|c.

Proof. We prove the first case by direct proof, Suppose that a|b and a|c, then from
the definition of divisibility, it follows that there are integers s and t with b = as
and c = at. Hence, b + c = as + at = a(s + t). Therefore a divides b + c.

Corollary 2.0.5. If a, b and c are integers, where a 6= 0, such that a|b and a|c then
a|mb + nc where m and n are integers.

Proof. We give a direct proof of part two of the theorem, where we see that a|mb
and a|nc whenever m and n are integers. By part one the theorem it follows that
a|mb + nc.

2.0.2 Division Algorithm

When an integer is divided by a positive integer, there is a quotient and a re-


mainder as the division algorithm shows,

Theorem 2.0.6. Let a be an integer and d a positive integer, then there are unique inte-
gers q and r, with 0 ≤ r < d such that a = dq + r

20
Definition 2.0.7. In the equality given in the division algorithm, d is called the
divisor, a is called the dividend, q is called the quotient and r is called the re-
mainder. This notation is used to express the quotient and remainder.

q = adivd

,
r=a mod d

Example 2.0.8. : What are the quotient and remainder when 101 is divided by
11?
Solution
101 = 11 · 9 + 2, hence the quotient when 101 is divided by 11 is 9 = 101 div11,
and remainder is 2 = 101 mod 11.

Example 2.0.9. : What are the quotient and remainder when −11 is divided by
3?
Solution
We have−11 = 3(−4) + 1 hence the quotient when −11 is divided by 3 is −4 =
−11div3, and the remainder is 1 = 11 mod 3.
Note
The remainder cannot be negative. Consequently, the remainder is not −2 even
though −11 = 3(−3) − 2 because r = −2 does not satisfy 0 ≤ r < 3.

Remark 2.0.10. An integer a is divisible by integer d if and only if the remainder


is zero when a is divided by d.

2.0.3 Modular Arithmetic

In some situations we are only interested on the remainder of the integer when
its is divided by some specified positive integer. Because we are interested in the
remainder, we have a special notation ffro them. We write a mod m to represent
the remainder when an integer a is divided by the positive integer m.

21
Definition 2.0.11. if a and b are integers and m is a positive integer, then a is
congruent to b( mod m) if m divides a − b. We use the notation a ≡ b( mod m)
to indicate that a is congruent to b modulo m. We say that a ≡ b( mod m) is a
congruence and that m is its modulus (plural moduli). If a and b are not congruent
modulo m we write a 6≡ b( mod m)

Theorem 2.0.12. Let a and b be integers, and let m be a positive integer. Then a ≡ b(
mod m) if and only if a mod m = b mod m.

Example 2.0.13. Determine whether 17 is congruent to 5 modulo 6 and whether


24 and 14 are congruent modulo 6

Solution
Because 6 divides 17 − 5 = 12, we see that 17 ≡ 5( mod 6). However, because
24 − 14 = 10 is not divisible by 6, we see that 24 ≡ 14( mod 6)

Theorem 2.0.14. Let m be a positve integer. The integer a and b are congruent modulo
m if snd only if there is an integer k such that a = b + km

Proof. If a ≡ b( mod m) then by definition of congruence we know that m|( a −


b). This means that there is an integer k such that a − b = km, so that a = b + km.
Conversly, if there is an integer k such that a = b + km, then km = a − b. Hence
m divides a − b so that a = b( mod m)

Theorem 2.0.15. Let m be a positive integer. If a ≡ b( mod m) and c ≡ d( mod m)


then a + c ≡ (b + d)( mod m) and ac ≡ bd( mod m).

Proof. We use direct proof. Because a ≡ b( mod m) and c ≡ d( mod m) then


there are integers s and t with b = a + sm and d = c + tm, Hence
b + d = ( a + sm) + (c + tm) = ( a + c) + m(s + t) and
bd = ( a + sm)(c + tm) = ac + m( at + cs + stm) Hence
a + c ≡ (b + d)( mod m) and ac ≡ bd( mod m)

Example 2.0.16. Because 7 ≡ 2( mod 5) and 11 ≡ 1( mod 5) it follows that


18 = 7 + 11 ≡ 2 + 1 = 3( mod 5)

22
and
77 = 7 × 11 ≡ 2 · 1 = 2( mod 5)

Corollary 2.0.17. Let m be a positive integer and let a and b be integers then, ( a + b)
mod m = {( a mod m) + (b mod m)} mod m and ab mod m = {( a mod m)(b
mod m)} mod m

Proof. By the defination of mod m and of congruence modulo m, we know that


a ≡ a( mod m)( mod m) and b ≡ b( mod m)( mod m) Hence, a + b ≡ ( a
mod m) + (b mod m)( mod m) and ab ≡ ( a mod m)(b mod m)( mod m)

2.0.4 Arithmetic Modulo M

We can define arithmetic operations on Zm , the set of nonnegative integers less


than m, that is the set {0, 1, · · · m − 1}. In particular, we define addition of these
integers denoted by +m by a +m b = ( a + b) mod m. Where the addition on
the right hand side of this equation is the ordenary addition of integers, and we
define multiplication of these integers, denoted by .m by a ·m b = ( a · b) mod m.
The operation +m and .m are called addition and multiplication modulo m, and
when we use these operations, we are said to be doing arithmetic modulo m.

Example 2.0.18. Use the definition of addition and multiplication in Zm to find


7 +11 9 and 7.11 9

Solution
7 +11 9 = (7 + 9) mod 11 = 16 mod 11 = 5
and
7.11 9 = (7 · 9) mod 11 = 63 mod 11 = 8

Conditions satisfied by +m and .m

1. Closure. If a and b belong to Zm then a +m b and a.m b belong to Zm .

23
2. Associativity. If a,b and c belong to Zm then, ( a +m b) +m c = a +m (b +m c)
and ( a.m b).m c = a.m (b.m c)

3. Comutativity. If a and b belong to Zm then a +m b = b +m a and a.m b = b.m a

4. Identity element.The element 0 and 1 are identity elements for addition and
multiplication modulo m respectively. If a belongs to Zm then a +m 0 =
0 +m a = a and a.m 1 = 1.m a = a

5. Additive inverse. If a 6= 0 belongs to Zm , then m − a is an additive inverse of


amodulo m and 0 is its own additive inverse. That is a +m (m − a) = 0 and
0 +m 0 = 0

6. Distributivity. If a, b and c belong to Zm then a.m (b +m c) = ( a.m b) +m ( a.m c)


and ( a +m b).m c = ( a.m c) +m (b.m c)

2.0.5 Integer representations and Algorithms

Integers can be expressed using any integer greater than one as the base. Al-
though commonly used base is decimal (base 10) representations, binary(base
2),octal (base 8) and hexadecimal (base 16) representations are often used in com-
puter science.
In this section we will show how to construct the base b of an integer n.

Representation of integers

Theorem 2.0.19. Let b be an integer greater than 1, then if n is a positive integer, it can
be expressed uniquely in the form n = ak bk−1 + · · · + a1 b + a· , where k is a nonnegative
integer a· a1 , · · · , ak are nonnegative integers less than b and ak 6= 0.

The above representation of n in the above theorem is called base b expansion of


n. Its denoted by ak ak−1 · · · a1 a·

24
Binary Expansion

Choosing 2 as the base gives binary expansion of the integer. In binary notation
each digit is either 0 or 1.

Example 2.0.20. What is the decimal expansion of the integer whose binary rep-
resentation is (101011111)2

Solution
(101011111)2 = 1 · 28 + 0 · 27 + 1 · 26 + 0 · 25 + 1 · 24 + 1 · 23 + 1 · 22 + 1 · 21 + 1 · 20 =
351

Example 2.0.21. Find the binary expansion of (241)10

Solution
First we devide 241 by 2
241 = 2 · 120 + 1
120 = 2 · 60 + 0
60 = 2 · 30 + 0
30 = 2 · 15 + 0
15 = 2 · 7 + 1
7 = 2·3+1
3 = 2·1+1
1 = 2·0+1
Therefore
(241)10 = (11110001)2

2.1 PRIMES AND GCD

Definition 2.1.1. A prime is an integer greater than 1 that is divisible by no pos-


itive integer except 1 and itself.

25
Definition 2.1.2. A positive integer that is greater than 1 and is not prime is aclled
composite.
The integer n is composite if and only if there exist an integer a such that a|n and
1 < a < n.

Example 2.1.3. 7 is prime because it is divisible by 1 and 7 only and 9 is composite


since it is divisible by 3.

Theorem 2.1.4. [Fundamental Theorem of arithmetic] Every integer greater than 1 can
be written uniquely as a prime or a product of two or more primes where the prime factors
are written in the order of nondecreasing size.

Example 2.1.5. The prime factorization of 100, 641, 999 and 1024 are given by:

1. 100 = 2 · 2 · 2 · 5 · 5 = 22 52

2. 641 = 641

3. 999 = 3 · 3 · ·3 · 37 = 33 37

4. 1024 = 2 · 2 · 2 · 2 · 2 · 2 · 2 · 2 · 2 · 2 = 210

Example 2.1.6. Show that 101 is prime.

Solution

The only prime not exceeding 101 are 2,3,5 and 7. Because 101 is not divisible
by 2,3,5 and 7, it follows that 101 is prime.

Example 2.1.7. Find the prime factorization of 7007

Solution
To find prime factorization of 7007, first we perfom division of 7007 by successive
primes, begining with 2, non of the primes 2,3 and 5 divides 7007. However, 7 di-
vides 7007 with 7007|7 = 1001. Next divide by successive primes begining with
7 its immediately seen that 7 also divides 1001 because 1001|7 = 143 continue
dividing 143 by successive primes,beginning with 7, although 7 does not divide

26
143, 11 does divide 143 and 143|11 = 13. Because 13 is prime, the procedure is
completed it follows that
7007 = 7 · 1001 = 7 · 7 · 143 = 7 · 7 · 11 · 13. consequently the prime factorization
of 7007 = 72 · 11 · 13

2.1.1 The seive of Erastothenes

Note that the composite integers not exceeding 100 must have prime factors not
exceeding 10. Because the only prime less than 10 are 2,3,5 and 7, the primes not
exceeding 100 are these four primes and those positive integers greater than 1
and not exceeding 100 that are divisible by non of 2,3,5 or 7.
The seive of Erastothenes is used to find all primes not exceeding a specified
positive integer.

Theorem 2.1.8. There are infinitely many primes

Proof. We use proof by contradiction, we assume that there are only finitely many
primes p1 p2 · · · , pn . Let Q = p1 p2 · · · pn+1 . By the fundamental theorem of
arithmetics Q is prime or else it can be written as the product of two or more
primes. However, non of the primes p j divides Q for is p j | Q then p j divides
Q − p1 p2 · · · pn = 1. Hence there is a prime not in the list p1 p2 · · · pn . This prime
is either Q if it is prime or a prime factcor of Q. This is a contradiction because
we assumed that we have listed all the primes. Consequently there are inifinitely
many primes.

Definition 2.1.9. [Mersenne Prime]: Are largest prime of the form 2 p − 1 where
p is also prime.

Example 2.1.10. The numbers 22 − 1 = 3, 23 − 1 = 7 , 25 − 1 = 31 and 27 − 1 =


127 are Mersenne primes while 211 − 1 = 2047 is not Mersenne prime because
2047 = 23 · 89

Theorem 2.1.11. [Prime number Theorem] The ratio of the number of primes not ex-
ceeding x and x/ ln x approaches 1 as x grows without bound.

27
2.1.2 GCD and LCM

Definition 2.1.12. Let a and b be integers, not both zero. The largest integer d
such that d| a and d|b is called the greatest divisor of a and b denoted by gcd(a,b).

Example 2.1.13. What is the greatest divisor of 24 and 36?

Solutio
The positive divisors of 24 and 36 are1,2,3,4,6 and 12. Hence gcd(24, 36)=12.

Definition 2.1.14. The integer a and b are relatively prime if their greatest com-
mon divisor is 1.

Example 2.1.15. What is the gcd of 17 and 22?

Solution
17 and 22 have no common divisor other than 1.

Definition 2.1.16. The integers a1 , a2 , · · · an are pairwise relatively prime if gcd( ai , a j )=1
whenever 1 ≤ i < j ≤ n

Example 2.1.17. Determine whether 10, 17 and 21 are pairwise relatively prime
and whether integer 10, 19 and 24 are pairwise relatively prime.

Solution
Because gcd(10, 17) = 1, gcd(10, 21) = 1 and gcd(17, 21) = 1 we conclude that 10,
17 and 21 are pairwise relatively prime. However, because gcd(10, 24) = 2 > 1
we see that 10, 19 and 24 are not pairwise relatively prime.

Remark 2.1.18. We can also find gcd of integers by using prime factorization
of the integers. i.e if a = p1a1 p2a2 · · · pnan and b = p1b1 p2b2 · · · pbnn the gcd( a, b) =
min( a1 ,b1 ) min( a2 ,b2 ) min( an ,bn )
p1 p2 · · · pn .

Example 2.1.19. Find the gcd(120, 500)

Solution
120 = 22 · 3 · 5 and 500 = 22 · 53 so
gcd(120, 500) = 2min(3,2) · 3min(1,0) · 5min(1,3) = 22 · 30 · 51 = 20

28
2.1.3 LCM

Definition 2.1.20. The least common multiple of a positive integer a and b is the
smallest positive integer that is divisible by both a and b denoted by lcm( a, b).
max ( a1 ,b1 ) max ( a2 ,b2 ) max ( an ,bn )
lcm is given by lcm( a, b) = p1 p2 · · · pn .

Example 2.1.21. what is the the least common multiple of 23 35 72 and 24 33 ?

Solution
lcm23 35 72 , 24 33 =2max(3,4) · 3max(5,3) · 7max(2,0) = 34 · 35 · 72

Theorem 2.1.22. Let a and b be positive integers then,ab = gcd( a, b) · lcm( a, b)

2.1.4 The Euclidean Algorithm

Lemma 2.1.23. Let a = bq + r, where a, b, q and r are integers, then gcd( a, b)=gcd(b, r )

Proof. We need to show taht the gcd of a and b are the same as the gcd of b and
r. Suppose that d divides both a and b, then it follows that d also divides a −
bq = r. Hence any common divisor of a and b is also common divisor of b and
r. Likewise, suppose that d divides both b and r, then d also divides bq + r =
a. Hence any common divisor of b and r is also a common divisor of a and b.
Consequently gcd( a, b) = gcd(b, r )

Note
Suppose that a and b are positive integers with a ≥ b. Let r0 = a and r1 = b.
When we succesively apply the division algorithm, we obtain
r0 = r1 q1 + r2 0 ≤ r2 < r1
r1 = r2 q2 + r3 0 ≤ r3 < r2
..
.
r n −2 = r n −1 q n −1 + r n 0 ≤ r n < r n −1
r n −1 = r n q n

29
Eventually a remainder of zero occurs in this sequence of successive divisions
because the sequence of remainders a = r0 > r1 > · · · ≥ 0 cannot contain more
than a terms. Further more, it follows from Lemma (4.1.23) that
gcd( a, b) = gcd(r0 , r1 ) = gcd(r1 , r2 ) = · · · = gcd(rn−2 , rn−1 ) = gcd(rn−1 , rn ) =
gcd(rn , 0) = rn
Hence the greatest common divisior is the last non zero remainder in the se-
quence of divisors.

Example 2.1.24. Find the gcd of 414 and 662 using the Euclidean Algorithm

Solution
Successive use of divison algorithm gives,
662 = 414 · 1 + 248
414 = 248 · 1 + 166
248 = 166 · 1 + 82
166 = 82 · 2 + 2
82 = 41 · 2
hence gcd(414, 662) = 2 because 2 is the last non zero remainder

2.1.5 GCD and Linear Combinations

The gcd of integer a and bcan be expressed in the form sa + tb wher s and t are
integers. In other words, gcd( a, b) can be expressed as linear combination with
integer coeffcients of a and b

Example 2.1.25. gcd(6, 14) = 2 and 2 = (−2) · 6 + 1 · 14

Theorem 2.1.26. [Bezout’s Theorem] If a and b are positive integers then there exist s
and t such that gcd( a, b) = sa + tb

Definition 2.1.27. If a and b are positive integers then integers s and t such
that gcd( a, b) = sa + tb are called Bezout’s coefficients of a and b. Also equation
gcd( a, b) = sa + tb is called Bezout’s identity.

30
Example 2.1.28. Express gcd(252, 198) = 18 as a linear combination of 252 and
198

Solution
We use Euclidean algorithm to show that gcd(252, 198) = 18
252 = 1 · 198 + 54
198 = 3 · 54 + 36
54 = 1 · 36 + 18
36 = 2 · 18
Using the next to last division we express gcd(252, 198) = 18 as a linear combi-
nation of 54 and 36. We find that
18 = 54 − 1 · 36
Second division tells us that 36 = 198 − 3 · 54 hence
18 = 54 − 1 · 36 = 54 − 1 · (198 − 3 · 54) = 4 · 54 − 1 · 198
From first division we see that 54 = 252 − 1 · 198 so,
18 = 54 − 1 · 36 = 54 − 1 · (198 − 3 · 54) = 4 · 54 − 1 · 198 = 4(252 − 1 · 198) − 1 ·
198 = 4 · 252 − 5 · 198
Thus 18 = 4 · 252 − 5 · 198

2.1.6 Linear Congruence

A congruence of the form ax ≡ b( mod m) where m a positive integer a and


b are integersand x is a variable is called linear congruence. Solving the linear
congruence ax ≡ b( mod m) is simply the same as finding all integers x that
satify this congruence.
One method that we will describe uses an integer ā such that a ā ≡ 1( mod m),
if such an integer exists, then ā is called the inverse of a modulo m.

Theorem 2.1.29. If a and m are relatively prime integers and m > 1, then an inverse of
a modulo m exists. Furthermore, this inverse is unique modulo m

Proof. Because gcd( a, m) = 1, there are integers s and t such that sa + tm = 1 this

31
implies that sa + tm ≡ 1( mod m). Because tm ≡ 0( mod m) it follows that
sa ≡ 1( mod m). Consequently, s is an inverse of a modulo m.

Example 2.1.30. Find the inverse of 3 modulo 7 by first finding Benzouts coeffi-
cients of 3 and 7.

Solution
Since gcd(3, 7) = 1 therefore the inverse of 3 modulo 7 exist. 7 = 2 · 3 + 1 from
this equation we see that −2 · 3 + 1 · 7 = 1 this shows that −2 and 1 are the
Bezout’s coefficients of 3 and 7. we see that −2 is the inverse of 3 modulo 7

Example 2.1.31. Find the inverse of 101 modulo 4620

Solution
4620 = 45 · 101 + 75
101 = 1 · 75 + 26
75 = 2 · 26 + 23
26 = 1 · 23 + 3
23 = 7 · 3 + 2
3 = 1·2+1
2 = 2·1
Because the last nonzero remainder is 1 then the gcd(101, 4620) = 1 we can find
the Bezout’s ciefficients.

32
1 =3 − 1 · 2

=3 − 1(23 − 7 · 3)
=8 · 3 − 1 · 23
=8(26 − 1 · 23) − 1 · 23
=8 · 26 − 9 · 23
=8 · 26 − 9(75 − 2 · 26)
=26 · 26 − 9 · 75
=26(101 − 1 · 75) − 9 · 75
=26 · 101 − 35 · 75
=26 · 101 − 35(4620 − 45 · 101)
=1601 · 101 − 53 · 4620

Thus −35 and 1601 are Bezout’s coefficients of 4620 and 101, and 1601 is an in-
verse of 101 modulo 4620.
Ones we have an inverse ā of a modulo m, we can solve the congruence ax ≡ b(
mod m) by multiplying both sides of the linear congruence by ā.

Example 2.1.32. What are the solutions of the linear combination 3x ≡ 4( mod 7)?

Solution
We now know that −2 is the inverse 3 modulo 7. Multiplying both sides of the
congruence by −2 shows that
−2 · 3x ≡ −2 · 4( mod 7)
Because −6 ≡ 1( mod 7) and −8 ≡ 6( mod 7) it follows that if x is a solution
then x ≡ −8 ≡ 6( mod 7). We need to determine whether every x with 6(
mod 7) is a solution. Assume that x ≡ 6( mod 7) then it follows that 3x ≡
3 · 6 = 18 ≡ 4( mod 7) which shows that all such x satisfy the congruence. We
conclude that the solutions to the congruence are the integers such that x ≡ 6(
mod 7) normally 6, 13, 20, · · · and −1, −8, −15,· · · .

33
2.1.7 The Chinese Remainder

Theorem 2.1.33. [The chinese Remainder Theorem]: Let m1 , m2 , · · · , mn be pairwise


relatively prime positive integers greater than one and a1 , a2 , · · · , an arbitrary integers.
Then the system
x ≡ a1 ( mod m1 )
x ≡ a2 ( mod m2 )
..
.
x ≡ an ( mod mn )
has a unique solution modulo m = m1 m2 · · · mn

34

You might also like