You are on page 1of 35

A First Course in Discrete Mathematics

Shubh N. Singh

Department of Mathematics
Central University of South Bihar
Gaya (Bihar), India
Contents

Contents i

Preface 1

1 Linear Diophantine Equations 3


1.1 Solved Problems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
1.2 Exercises on Linear Diophantine Equations . . . . . . . . . . . . . . . . . . 9

2 Prime Numbers 11
2.1 Euclid’s Lemma . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
2.2 Prime Numbers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
2.3 Solved Problems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13

3 Fermat’s Theorem 15
3.1 Solved Problems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
3.2 Exercises on Fermat’s Theorem . . . . . . . . . . . . . . . . . . . . . . . . . 18

4 Linear Congruences 19
4.1 Solved Problems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
4.2 Objective Questions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
4.3 Exercises on Linear Congruence Equations . . . . . . . . . . . . . . . . . . . 22

5 The Chinese Remainder Theorem (CRT) 23


5.1 Solved Problems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
5.2 Exercises on the CRT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24

6 Wilson’s Theorem 27
6.1 Solved Problems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
6.2 Exercises on Multiplicative Inverse . . . . . . . . . . . . . . . . . . . . . . . 28

7 Euler-Phi Functions 29
7.1 Solved Problems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
7.2 Exercises on Euler Phi functions . . . . . . . . . . . . . . . . . . . . . . . . 30

Bibliography 31

Index 32

i
ii CONTENTS
Preface

The notion of group theory first came into light in the course of as early as 1770 by Joseph
Louis Lagrange. In the vicinity of 1830. Evariste. Galois extended Lagrange’s work in
the exploration of solutions of equations and introduced firstly the term ‘group’. During
those days, mathematicians were working with groups of transformations. These were
nothing, but the collection of mappings, that, under, operation possesses certain attributes.
In the beginning, a group was a set of permutations (i.e.. one-to-one correspondence
/bijection) with the characteristic that the combination of any two permutations is again
a permutation and belongs to the same set. Mathematicians like Felix Klein (1849-1925),
a German mathematician take on the idea to amalgamate areas of geometry. In 1870,
Leopold Kronecker (1823-1891) proposed a set of axioms for a group. The concept of the
group proposed earlier was generalized to the present concept ’of an abstract group during
the first decade of the twentieth’ century’, which was defined by virtue of a set of axioms.
The theory and concept of abstract groups play a very important role in present-day
science and mathematics. Indeed, the concept of groups arises in a number of seemingly
unconnected disciplines. The word-groups appear in analysis, topology, algebra, geometry,
computer science, chemistry, physics, economics, and biology, etc. So the study of groups
is indispensable and very fascinating. In this book, our aim surrounds the study of groups
and the properties they hold.
The theory of groups is regarded as the branch of abstract algebra. The first fruitful
and productive use of groups was made in the early nineteenth century by Augustin Louis
Cauchy (1789-1857) and Evariste Galois (1811-1932) . They used groups in order to de-
scribe the effect of permutations on the roots of a polynomial equation. What they use
as groups were not based on an axiomatic approach. In 1854, Arthur Cayley (1821-1895)
firstly proposed the axioms for a group. However, the concept proposed by Cayley was lost
sight of. Kronecker again come out with the postulates for an Abelian group in 1870. H.
Weber proposed the notion for finite groups in 1882 and the concept for infinite groups in
1883. As discussed earlier, the notion of a group arose from the study of one-one functions
on the set of roots of a polynomial equation. We have seen that the set G of all one-one
functions from a set A onto itself satisfies the following properties:

1
2 CONTENTS
Chapter 1

Linear Diophantine Equations

Definition 1.0.1. Let a, b, and c be integers such that a and b are not both zero. Then
the equation
ax + by = c
is called the linear Diophantine equation in two unknowns.

A solution of this linear Diophantine equation in two unknowns: ax + by = c is a pair


of integers x0 , y0 which satisfy the given equation when substituted into it.

Example 1.0.2. Consider the following linear Diophantine equation in two unknowns:

3x + 6y = 18.

Observe that

(i) the pair (4, 1) is a solution of 3x + 6y = 18, since 3 · 4 + 6 · 1 = 18

(ii) the pair (−6, 6) is a solution of 3x + 6y = 18, since 3 · (−6) + 6 · 6 = 18

(iii) the pair (10, −2) is a solution of 3x + 6y = 18, since 3 · 10 + 6 · (−2) = 18

Example 1.0.3. Consider the following linear Diophantine equation in two unknowns:

2x + 10y = 17.

Observe that the left-hand side of the equation is an even number whatever the choice of
integers x and y. However, the right-hand side of the equation is an odd integer. Hence
there is no solution to this equation 2x + 10y = 17.

Faced with this, it is reasonable to enquire about the circumstances under which a
solution is possible and, when a solution does exist, whether we can determine all the
solutions explicitly.

Theorem 1.0.4. A linear Diophantine equation ax + by = c in two unknowns has a


solution if and only if gcd(a, b) divides c.

3
4 CHAPTER 1. LINEAR DIOPHANTINE EQUATIONS

Proof. Write d := gcd(a, b). Then clearly d | a and d | b. This implies that a = dr and
b = ds for some integers r, s ∈ Z.
First, suppose that ax + by = c has a solution, say (x0 , y0 ). This gives ax0 + by0 = c.
Therefore

c = ax0 + by0
= (dr)x0 + (ds)y0
= d(rx0 + sy0 ).

This implies that d := gcd(a, b) divides c.


Conversely, suppose that d := gcd(a, b) divides c. Then c = dt for some integer t ∈ Z.
Now since d = gcd(a, b), we have d = ax0 + by0 for some integers x0 , y0 ∈ Z. Therefore we
obtain

c = dt
= (ax0 + by0 )t
= a(tx0 ) + b(ty0 ).

Hence ax + by = c has a solution (tx0 , ty0 ).

Example 1.0.5. The linear Diophantine equation 6x + 51y = 22 in two unknowns has no
solution, since gcd(6, 51) = 3 but 3 does not divide 22.

Example 1.0.6. The linear Diophantine equation 33x + 14y = 115 in two unknowns has
a solution, since gcd(33, 14) = 1 and 1 divides 115.

Example 1.0.7. The linear Diophantine equation 14x + 35y = 93 in two unknowns has
no solution, since gcd(14, 35) = 7 but 7 does not divide 93.

Example 1.0.8. The linear Diophantine equation 56x + 72y = 40 in two unknowns has a
solution, since gcd(56, 72) = 8 and 8 divides 40.

Example 1.0.9. The linear Diophantine equation 24x + 138y = 18 in two unknowns has
a solution, since gcd(24, 138) = 6 and 6 divides 18.

Problem 1.0.10. Which of the following linear Diophantine equations in two unknowns
can not be solved?

(i) 221x + 35y = 11.

(ii) 18x + 5y = 48.

(iii) 54x + 21y = 906.

(iv) 123x + 360y = 99.


1.1. SOLVED PROBLEMS 5

Theorem 1.0.11. If (x0 , y0 ) is a solution of a linear Diophantine equation ax + by = c in


two unknowns, then all other solutions of this equation are given by
b a
x = x0 + t y = y0 − t,
d d
where t is an integer.
Proof.

Example 1.0.12. Consider the following linear Diophantine equation in two unknowns:

3x + 6y = 18.

Note that a = 3, b = 6, and d := gcd(3, 6) = 3. Observe that the pair (4, 1) is a solution of
3x + 6y = 18, since 3 · 4 + 6 · 1 = 18. Say x0 = 4 and y0 = 1.
(i) the pair (−6, 6) is a solution of 3x + 6y = 18, since 3 · (−6) + 6 · 6 = 18. Also
6 3
−6 = 4 + (−5) 6 = 1 − (−5)
3 3

(ii) the pair (10, −2) is a solution of 3x + 6y = 18, since 3 · 10 + 6 · (−2) = 18. Also
6 3
10 = 4 + ·3 −2=1− ·3
3 3

1.1 Solved Problems


Problem 1.1.1. Determine whether the following linear Diophantine equation in two un-
knowns has a solution.
5x + 22y = 18.
If a solution of the equation exists, then find it.
Solution. First, applying the Euclidean’s algorithm to the evaluation of gcd(5, 22), we
find that

22 = 4 · 5 + 2
5=2·2+1
2 = 2 · 1 + 0.

Thus gcd(5, 22) = 1. Since 1 | 18, the equation 5x + 22y = 18 has a solution.
Note that 18 = 1 · 18. So, we first write 1 := gcd(5, 22) as a linear combination of 5
and 22. For this, we work backward through the previous calculations as follows:

1=5−2·2
= 5 − 2 · (22 − 4 · 5)
= 5 − 2 · 22 + 8 · 5
= 9 · 5 − 2 · 22
6 CHAPTER 1. LINEAR DIOPHANTINE EQUATIONS

Thus we have 1 = 9 · 5 + (−2) · 22. Hence, we obtain

18 = 18 · 1
= 18 · (9 · 5 + (−2) · 22)
= 162 · 5 + (−2 · 18) · 22
= 162 · 5 + (−36) · 22.

Hence x = 162 and y = −36 is a solution to the linear Diophantine equation 5x + 22y = 18.
All other solutions are given by
 22  5
x = 162 + t = 162 + 22t y = (−36) − t = −36 − 5t,
1 1
where t is an integer. 

Problem 1.1.2. Determine whether the following linear Diophantine equation in two un-
knowns has a solution.
172x + 20y = 1000.
If a solution of the equation exists, then find it.

Solution. Applying the Euclidean’s Algorithm to the evaluation of gcd(172, 20), we find
that

172 = 8 · 20 + 12
20 = 1 · 12 + 8
12 = 1 · 8 + 4
8=2·4+0

Thus gcd(172, 20) = 4. Since 4 | 1000, the equation 172x + 20y = 1000 has a solution.
Note that 1000 = 4 · 250. So, we first write 4 := gcd(172, 20) as a linear combination
of 172 and 20. For this, we work backward through the previous calculations as follows:

4 = 12 − 8
= 12 − (20 − 12)
= 2 · 12 − 20
= 2 · (172 − 8 · 20) − 20
= 2 · 172 − 17 · 20

Thus we have 4 = 2 · 172 + (−17) · 20. Multiplying this relation by 250, we obtain

1000 = 250 · 4
= 250 · (2 · 172 + (−17) · 20)
= 500 · 172 + (−17 · 250) · 20
= 500 · 172 + (−4250) · 20.
1.1. SOLVED PROBLEMS 7

Hence x = 500 and y = −4250 is a solution to the linear Diophantine equation 172x+20y =
1000. All other solutions are given by

 20   172 
x = 500 + t = 500 + 5t y = (−4250) − t = (−4250) − 43t,
4 4
where t is an integer. 

Problem 1.1.3. Find all the solutions (x, y) to the following Diophantine equation for
which x and y are both positive integers:

11x + 13y = 369.

Solution. Applying the Euclidean’s algorithm, we get

13 = 1 · 11 + 2
11 = 5 · 2 + 1
2 = 2 · 1 + 0.

Therefore gcd(13, 11) = 1, and so gcd(13, 11) divides 369. Therefore the linear Diophantine
equation 11x + 13y = 369 has a solution.
We now write 1 := gcd(13, 11) as a linear combination of 13 and 11. For this, we work
backward through the previous calculations as follows:

1 = 11 − 5 · 2
= 11 − 5 · (13 − 11)
= 11 · 6 + 13 · (−5).

Hence

369 = 369 · 1
= 369 · (11 · 6 + 13 · (−5))
= 11 · 2214 + 13 · (−1845).

Thus x0 = 2214 and y0 = −1845 is a particular solution. The general solution is

x = 2214 + 13t, y = −1845 − 11t,

where t ∈ Z.
I want solutions for which x and y are both positive. This means that x > 0 and y > 0.
The inequality x > 0 gives 2214 + 13t > 0, and so t > − 2214 13 = −170.31.
The inequality y > 0 gives −1845 − 11t > 0, and so t < − 1845 11 = −167.73.
The integers t which satisfy both of these inequalities are t = −170, −169, −168.
Thus the solutions are (x, y) = (4, 25), (17, 14), and (20, 3).

8 CHAPTER 1. LINEAR DIOPHANTINE EQUATIONS

t x y
−170 4 25
−169 17 14
−168 20 3

Problem 1.1.4. Sam buys large shirts for $18 each and small shirts for $11 each. The
shirts cost a total of $1188. What is the smallest total number of shirts, he could have
bought?
Solution. Let x be the number of large shirts, and let y be the number of small shirts.
Then
18x + 11y = 1188.
Applying the Euclidean’s algorithm, we get

18 = 1 · 11 + 7
11 = 1 · 7 + 4
7=1·4+3
4=1·3+1
3 = 3 · 1 + 0.

Therefore gcd(18, 11) = 1, and so gcd(18, 11) divides 1188. Therefore the linear Diophan-
tine equation 18x + 11y = 1188 has a solution.
We now write 1 := gcd(18, 11) as a linear combination of 18 and 11. For this, we work
backward through the previous calculations as follows:

1=4−3
= 4 − (7 − 4)
=2·4−7
= 2 · (11 − 7) − 7
= 2 · 11 − 3 · 7
= 2 · 11 − 3 · (18 − 11)
= 18 · (−3) + 11 · 5.

Hence

1188 = 1188 · 1
= 1188 · (18 · (−3) + 11 · 5)
= 18 · (−3564) + 11 · 5940.

Thus x0 = −3564 and y0 = 5940 is a particular solution. The general solution is

x = −3564 + 11t, y = 5940 − 18t,


1.2. EXERCISES ON LINEAR DIOPHANTINE EQUATIONS 9

where t ∈ Z.
Since the number of shirts can not be negative, we have x ≥ 0 and y ≥ 0.
The inequality x ≥ 0 gives −3564 + 11t ≥ 0, and so t ≥ 356411 = 324.
5940
The inequality y ≥ 0 gives 5940 − 18t ≥ 0, and so t ≤ 18 = 330. Thus 324 ≤ t ≤ 330.
The total number of shirts is x + y = (−3564 + 11t) + (5940 − 18t) = 23767t.
For 324 ≤ t ≤ 330, this is smallest for t = 330, which gives

x = 66, y = 0, x + y = 66.

Hence we conclude that Sam bought 66 large shirts, no small shirts, and a total of 66
shirts. 

1.2 Exercises on Linear Diophantine Equations


1. Find integers x and y such that 2173x + 2491y = 53.

2. Determine whether the linear Diophantine equation 155x + 45y = 7 has a solution.
If yes, then find a solution of it.

3. Determine whether the linear Diophantine equation 60x + 33y = 9 has a solution. If
yes, then find a solution of it.

4. Determine whether the linear Diophantine equation 858x + 253y = 33 has a solution.
If yes, then find a solution of it.

5. Determine whether the linear Diophantine equation 2173x + 2491y = 210 has a
solution. If yes, then find a solution.

6. Find all integer solutions to the linear Diophantine equation 2173x + 2491y = 159.

7. Determine whether the linear Diophantine equation 258x+147y = 369 has a solution.
If yes, then find a solution of it.

8. Let x and y be integers such that x + y = 100. If x is divisible by 7 and y is divisible


by 11, then determine x and y.

9. Find all integer solutions to the linear Diophantine equation 7x − 9y = 3.

10. Find all integer solutions to the linear Diophantine equation 258x + 147y = 369.

11. Find a general solution of the linear Diophantine equation 641x + 372y = 1254.
10 CHAPTER 1. LINEAR DIOPHANTINE EQUATIONS
Chapter 2

Prime Numbers

2.1 Euclid’s Lemma


Proposition 2.1.1. Let a, b, c ∈ Z and a 6= 0. If a | b and a | c, then a | bc.

Proof. If a | b and a | c, then b = ar and c = as for some r, s ∈ Z. Consider the product

bc = (ar)(as) = a(ars).

This implies that a | bc.

The converse of the above proposition is not true, in general. For example,

12 | (8 · 9), but 12 - 8 and 12 - 9.

Lemma 2.1.2 (Euclid’s lemma). If a | bc and gcd(a, b) = 1, then a | c.

Proof. Since gcd(a, b) = 1, we have 1 = ax + by for some x, y ∈ Z. Then

c = c · 1 = c · (ax + by) = acx + bcy.

Note that a | ac. Given that a | bc. Therefore

a | ((ac)x + (bc)y) =⇒ a | acx + bcy =⇒ a | c.

2.2 Prime Numbers


Definition 2.2.1. A positive integer greater than 1 is called a prime number or simply
a prime if its only positive divisors are 1 and itself.

Example 2.2.2. The integers 2, 3, 5, 7, 11, 13, 17, 19 are first few prime numbers, since the
positive divisors of these positive integers are only 1 and themself.

Definition 2.2.3. A positive integer greater than 1 is called a composite number if it


is not a prime number.

11
12 CHAPTER 2. PRIME NUMBERS

Example 2.2.4. The integers 4, 6, 8, 9, 10 are first few composite numbers, since they are
not prime numbers.

Theorem 2.2.5. Let a, b ∈ Z. If p is a prime and p | ab, then p | a or p | b.

Proof. If p | a, then we are done. So, let us assume that p - a. Since p is prime, the only
positive divisors of p are 1 and p itself. This implies that gcd(p, a) = 1. Since p | ab, we
therefore obtain p | b by Euclid’s lemma.

By the mathematical induction, the above theorem easily extends to products of more
than two integers.

Corollary 2.2.6. Let a1 , a2 , . . . , an be integers. If p is a prime and p | a1 a2 . . . an , then


p | ak for some k, where 1 ≤ k ≤ n.

Proof. We proceed by induction on n, the number of factors. When n = 1, the stated


conclusion obviously holds; whereas when n = 2, the result is followed by Theorem 2.2.5.
Suppose, as the induction hypothesis, that n > 2 and that whenever p divides a product
of less than n factors, it divides at least one of the factors.
Now, let p | a1 a2 . . . an . From Theorem 2.2.5, either p | an or p | a1 a2 . . . an−1 . If p | an ,
then we are through. If p | a1 a2 . . . an−1 , the induction hypothesis ensures that p | ak for
some choice of k with 1 ≤ k ≤ (n − 1). Thus, in each case, p divides one of the integers
a1 , a2 , . . . , an .

Corollary 2.2.7. Let p, q1 , q2 , . . . , qn be prime numbers. If p | q1 q2 . . . qn , then p | qk for


some k, where 1 ≤ k ≤ n.

Proof. By Corollary 2.2.6, we know that p | qk for some k with 1 ≤ k ≤ n. Since qk is


prime, the number qk is not divisible by any positive integer other than 1 or qk itself. Since
p ≥ 2, we are forced to conclude that p = qk .

Theorem 2.2.8 (Fundamental Theorem of Arithmetic). Every positive integer greater


n than 1 can be expressed as a product of prime numbers; this representation is unique,
apart from the order in which the factors occur.

Proof. If n is prime, then there is nothing more to prove. So, let us assume that n is
composite. Then there exists an integer d such that d | n and 1 < d < n.
Among all such integers d, choose p1 to be the smallest (this is possible by the Well-
Ordering Principle). Then p1 must be a prime number. Otherwise it too would have a
divisor q with 1 < q < p1 ; but then q | p1 and p1 | n imply that q | n, which contradicts
the choice of p1 as the smallest positive divisor, not equal to 1, of n.
We therefore may write n = p1 n1 , where p1 is prime and 1 < n1 < n. If n1 happens
to be a prime, then we have our representation. In the contrary case, the argument is
repeated to produce a second prime number p2 such that n1 = p2 n2 ; that is,

n = p 1 p 2 n2 , 1 < n2 < n1 < n.


2.3. SOLVED PROBLEMS 13

If n2 is a prime, then it is not necessary to go further. Otherwise, write n2 = p3 n3 with


p3 a prime:
n = p1 p2 p3 n3 , 1 < n3 < n2 < n1 < n.
The decreasing sequence
n > n1 > n2 > · · · > 1
can not continue indefinitely, so that after a finite number of steps nk−1 is a prime, call it,
pk This leads to the prime factorization

n = p1 p2 p3 . . . pk .

2.3 Solved Problems


Problem 2.3.1. Let n be a positive integer. If 4 | n(n − 1), then show that 4 | n or
4 | (n − 1).

Solution. Note, by Euclid’s lemma, that if a | bc with gcd(a, b) = 1, then a | c. Since


n is odd or n − 1 is odd, it follows that gcd(4, n) = 1 or gcd(4, n − 1) = 1. Given that
4 | n(n − 1), by Euclid’s lemma, we get that 4 | (n − 1) or 4 | n. 
14 CHAPTER 2. PRIME NUMBERS
Chapter 3

Fermat’s Theorem

Theorem 3.0.2 (Fermat’s theorem). Let p be a prime and let a be an integer. If p - a,


then
ap−1 ≡ 1 mod p.
Fermat’s theorem is also called Fermat’s Little theorem.

Proof. Consider the following set S of (p − 1) integers:


S = {a, 2a, 3a, . . . , (p − 1)a}.
Notice that p - k for all k ∈ {1, 2, . . . , p − 1}. Since p is prime and p - a, we therefore
have p - ak for all k ∈ {1, 2, . . . , p − 1}. This implies that no element of S is congruent to
0 mod p.
Next, we claim that no two elements of S are congruent modulo p. Indeed, if ua, va ∈ S,
where u, v ∈ {1, 2, . . . , (p − 1)}, such that
ua ≡ va mod p =⇒ p | (ua − va) =⇒ p | (u − v)a.
Since p is prime and p - a, we obtain p | (u − v) =⇒ u ≡ v mod p. This is a contradiction.
Hence no two elements of S are congruent modulo p.
So, the elements of S must be congruent modulo p to 1, 2, 3, . . . , (p − 1) in some order.
Without loss of generality, assume that
a ≡ 1 mod p
2a ≡ 2 mod p
..
.
(p − 1)a ≡ (p − 1) mod p.
Then
a · 2a · 3a · · · (p − 1)a ≡ 1 · 2 · 3 · · · (p − 1) mod p =⇒ (p − 1)!ap−1 ≡ (p − 1)! mod p.
This yields
p | (p − 1)!ap−1 − (p − 1)! =⇒ p | (p − 1)!(ap−1 − 1) =⇒ p | (ap−1 − 1),
since gcd(p, (p − 1)!) = 1. Thus ap−1 ≡ 1 mod p.

15
16 CHAPTER 3. FERMAT’S THEOREM

We can use Fermat’s theorem as a labor-saving device in certain calculations.

Corollary 3.0.3. If p is a prime, then ap ≡ a mod p.

Proof. We consider the following two cases.


If p | a, then p | ap . Therefore p | (ap − a), and so ap ≡ a mod p.
If p - a, then ap−1 ≡ 1 mod p by Fermat’s Little theorem. This implies

p | (ap−1 − 1) =⇒ p | a(ap−1 − 1) =⇒ p | (ap − a) =⇒ ap ≡ a mod p.

If a | c and b | c, it is not true in general that ab | c. For example,

6 | 24 and 8 | 24, but (6 · 8) - 24.

Note here that gcd(6, 8) = 2 6= 1.

Corollary 3.0.4. Let a, b, c ∈ Z such that a | c and b | c. If gcd(a, b) = 1, then ab | c.

Proof. Since a | c and b | c, we have c = ar and c = bs for some r, s ∈ Z. Now, since


gcd(a, b) = 1, we obtain 1 = ax + by for some x, y ∈ Z. Therefore

c=c·1
= c(ax + by)
= acx + bcy
= a(bs)x + b(ar)y
= ab(sx + ry).

Hence ab | c.

Theorem 3.0.5. Let p and q be distinct primes. If ap ≡ a mod q and aq ≡ a mod p, then
apq ≡ a mod pq.

Proof. Since aq ≡ a mod p, it follows that (aq )p ≡ ap mod p. Combining the congruences
apq ≡ ap mod p and aq ≡ a mod p, we obtain apq ≡ a mod p. This means p | (apq − a).
Now, since ap ≡ a mod q, it follows that (ap )q ≡ aq mod q. Combining the congruences
apq ≡ aq mod q and ap ≡ a mod q, we obtain apq ≡ a mod q. This means q | (apq − a).
Since gcd(p, q) = 1, we therefore have pq | (apq − a), and thus apq ≡ a mod pq.

Exercise 3.0.6. Find the remainder when 20182018 is divided by 26.

3.1 Solved Problems


Problem 3.1.1. Find the remainder when 538 is divided by 11.
3.1. SOLVED PROBLEMS 17

Solution. Let a = 5 and p = 11. By Fermat’s theorem, we then get 510 ≡ 1 mod 11.
Now, we can write 38 = 10 · 3 + 8. So,

538 = 510·3+8 = (510 )3 · (52 )4 .

Since 510 ≡ 1 mod 11, it follows that (510 )3 ≡ 1 mod 11. Also, observe that 52 ≡
3 mod 11. Therefore (52 )4 ≡ 34 mod 11. Hence

538 = (510 )3 · (52 )4


≡ 1 · 34 mod 11
≡ 4 mod 11.

Hence the answer is 4. 

Problem 3.1.2. Calculate 50250 modulo 83 using Fermat’s theorem.


Solution. Notice that 83 is prime. By Fermat’s theorem, we know that 5082 ≡ 1 mod 83.
Applying the Division Algorithm between 250 and 82, we get

250 = 82 · 3 + 4.

Hence

50250 = 5082·3+4
= (5082 )3 · 504
≡ 13 · 504 mod 83
≡ 6250000 mod 83
≡ 17 mod 83.

Thus the answer is 17. 

Problem 3.1.3. Calculate the remainder when 20182018 is divided by 26.


Solution. Note that 26 is not a prime, but 26 = 2 · 13.
First, we notice that gcd(2018, 13) = 1. By Fermat’s little theorem, we get 201812 ≡
1 mod 13. Now, we see that 2018 ≡ 3 mod 13 and 2018 = 12 · 168 + 2. Therefore

20182018 = 201812·168+2
= (201812 )168 · 20182
≡ 1168 · 32 mod 13
≡ 9 mod 13.

This means

13 | 20182018 − 9 =⇒ 13 | (20182018 − 9) − 13 =⇒ 13 | 20182018 − 22.

Also, it is clear that 2 | 20182018 − 22. Since gcd(13, 2) = 1, therefore (13 · 2) | 20182018 − 22.
Hence 20182018 ≡ 22 mod 26. We conclude that the answer is 22. 
18 CHAPTER 3. FERMAT’S THEOREM

Problem 3.1.4. Calculate the last digit of 20182018 .

Solution. It suffices to find the remainder when 20182018 is divided by 10. Note that
10 = 2 · 5.
First, we notice that gcd(2018, 5) = 1. By Fermat’s little theorem, we get 20184 ≡
1 mod 5. Now, we see that 2018 ≡ 3 mod 5 and 2018 = 4 · 504 + 2. Therefore

20182018 = 20184·504+2
= (20184 )504 · 20182
≡ 1504 · 32 mod 5
≡ 4 mod 5.

Thus 5 | 20182018 − 4. Also, it is clear that 2 | 20182018 − 4. Since gcd(5, 2) = 1, therefore


(5 · 2) | 20182018 − 4. Hence 20182018 ≡ 4 mod 10. We conclude that the answer is 4. 

Problem 3.1.5. Calculate 364 modulo 67 using Fermat’s theorem.

Solution. By Fermat’s theorem, we know that 366 ≡ 1 mod 67. So

32 · 364 ≡ 1 mod 67 =⇒ 15 · 32 · 364 ≡ 15 mod 67 =⇒

Note that 15 · 9 ≡ 1 mod 67. 

3.2 Exercises on Fermat’s Theorem


1. Find 331 mod 7.

2. Find 235 mod 7.

3. Find 128129 mod 17.

4. Find 2925 mod 11.

5. Calculate 132010 mod 71.

6. Find the remainder when 21000 is divided by 13.

7. Find the remainder when 62000 is divided by 11.

8. Find the remainder when 281202 is divided by 13.

9. Find the remainder when 12347865435 is divided by 11.

10. Find (220 + 330 + 440 + 550 + 660 ) mod 7.


Chapter 4

Linear Congruences

Definition 4.0.1. A linear congruence equation is an equation of the form:

ax ≡ b (mod n),

where a, b ∈ Z, n ∈ N, and x is an unknown integer.


Definition 4.0.2. A solution of a linear congruence equation ax ≡ b (mod n) is any
integer x0 for which ax0 ≡ b (mod n).
Example 4.0.3. Consider the linear congruence equation: 3x ≡ 9 (mod 12). Then
(i) the integer x0 = 3 is a solution of the equation, since 3 · 3 ≡ 9 (mod 12).

(ii) the integer x0 = −9 is a solution of the equation, since 3 · (−9) ≡ 9 (mod 12).
In fact, any integer of the form 4 + 10k or of the form 9 + 10k where k ∈ Z is a solution to
the given linear congruence equation. The above linear congruence equation has infinitely
many integer solutions.
Example 4.0.4. Consider the linear congruence equation: 2x ≡ 1 (mod 4). Since 4 -
(2x − 1) for all x ∈ Z. Hence the equation 2x ≡ 1 (mod 4) has no solution.
Definition 4.0.5. Two solutions x1 and x2 of a linear congruence ax ≡ b mod n are said
to be equivalent if x1 ≡ x2 mod n.
Example 4.0.6. Two solutions x1 = 3 and x2 = −9 of the linear congruence 3x ≡
9 mod 12 discussed in Example 4.0.3 are equal, since 3 ≡ −9 mod 12.
Remark 4.0.7. If x0 is a solution of a linear congruence equation ax ≡ b (mod n), then
every integer of the set {x0 +nk : k ∈ Z} is also a solution of the linear congruence equation.
Such a set of solutions is called a solution class modulo n and denoted by [x0 ]n .
By definition of congruence, ax ≡ b (mod n) if and only if n | axb. Hence, ax ≡ b
(mod n) if and only if axb = ny for some integer y. Rearranging the equation to the
equivalent form axny = b, we arrive at the following result.
Lemma 4.0.8. Solving the linear congruence equation axb (mod n) is equivalent to solving
the linear Diophantine equation axny = b.

19
20 CHAPTER 4. LINEAR CONGRUENCES

Since we already know how to solve linear Diophantine equations, this means we can
apply that knowledge to solve linear congruence equations.
Theorem 4.0.9. Let a, b ∈ Z, let n ∈ N, and let d = gcd(a, n).
(i) If d - b, then the linear congruence equation ax ≡ b (mod n) has no solution.

(ii) If d | b, then the linear congruence equation ax ≡ b (mod n) has exactly d distinct
solution classes modulo n.
Proof. Solving the linear congruence equation ax ≡ b (mod n) is equivalent to solving the
linear Diophantine equation ax − ny = b.

(i) If d - b, then the linear Diophantine equation has no solution, so the linear congruence
equation has no solution, either.

(ii) If d | b, then the solutions of the linear Diophantine equation take the form:

n a
x = x0 + t, y = y0 + t
d d
where (x0 , y0 ) is any particular solution (obtained from the Euclidean algorithm, for
instance). To finish the proof, observe that as t runs through the values 0, 1, . . . , d1
(the residues modulo d) the congruence classes [x0 + nd t]n run through all the solutions.
(There are no other solutions because the classes just repeat for higher and lower
values of t.)

Example 4.0.10. Consider the linear congruence equation 6x ≡ 4 (mod 10). Note that it
has a solution, since d := gcd(6, 10) = 2 divides 4. we solve it by first guessing the solution
x0 = 4 by trial and error. Then the theorem tells us that [x0 + (10/2)t]10 for t = 0, 1 gives
the complete solution set. Thus, x = [4]10 and [9]10 is the complete solution.
As a special case of Theorem 4.0.9, let me point out that if d = gcd(a, n) = 1, then the
linear congruence equation ax ≡ b (mod n) has a unique solution class modulo n. In the
special case gcd(a, n) = 1, we can always solve the congruence by finding the inverse of
[a]m and then multiplying both sides of the congruence by the inverse to obtain the unique
solution. This is a satisfying idea because it is so similar to what we do in ordinary high
school algebra to solve linear equations.
Definition 4.0.11. Let n ∈ N and a be an integer. An inverse of a mod n is any integer
b such that a · b ≡ 1 (mod n). We write a−1 = b for the inverse just defined, when it exists.

An inverse of a mod n exists if and only if gcd(a, n) = 1.

Example 4.0.12. Consider the linear congruence equation 11x ≡ 15 (mod 20). Note
that the given equation has a unique solution class modulo 20, since d := gcd(11, 20) = 1
divides 15. Observe that 11 · 11 ≡ 1 (mod 20). Using this fact, we can solve the given
linear congruence equation simply by multiplying both sides by 11 and reducing numbers
mod20. Here we go:
4.1. SOLVED PROBLEMS 21

11x ≡ 15 (mod 20)


11 · 11x ≡ 11 · 15 (mod 20)
121x ≡ 165 (mod 20)
x≡5 (mod 20).

This proves that x = [5]20 is the unique solution to the given linear congruence equation
11x15 (mod 20).
Corollary 4.0.13. If gcd(a, n) = 1, then the linear congruence ax ≡ b mod n has a unique
solution modulo n. This unique solution is sometimes called the multiplicative inverse
of a modulo n.

4.1 Solved Problems

4.2 Objective Questions


1. The solution of the linear congruence equation x ≡ 2 (mod 3) is

(A) 0 (mod 3)
(B) 1 (mod 3)
(C) 2 (mod 3)
(D) none of these

2. The solution of the linear congruence equation x ≡ 3 (mod 5) is

(A) 4 (mod 5)
(B) 3 (mod 5)
(C) 2 (mod 5)
(D) 1 (mod 5)

3. The solution of the linear congruence equation x ≡ 6 (mod 11) is

(A) 2 (mod 11)


(B) 4 (mod 11)
(C) 6 (mod 11)
(D) 8 (mod 11)

4. The solution of the linear congruence equation 2x ≡ 3 (mod 7) is

(A) 6 (mod 7)
(B) 5 (mod 7)
(C) 4 (mod 7)
(D) 3 (mod 7)
22 CHAPTER 4. LINEAR CONGRUENCES

5. The solution of the linear congruence equation 3x ≡ 1 (mod 8) is

(A) 6 (mod 8)
(B) 5 (mod 8)
(C) 4 (mod 8)
(D) 3 (mod 8)

6. The solution of the linear congruence equation 4x ≡ 5 (mod 9) is

(A) 6 (mod 9)
(B) 8 (mod 9)
(C) 9 (mod 9)
(D) 10 (mod 9)

7. The solutions of the linear congruence equation 2x ≡ 2 (mod 4) are

(A) 1 (mod 4) and 2 (mod 4)


(B) 1 (mod 4) and 3 (mod 4)
(C) 2 (mod 4) and 3 (mod 4)
(D) 0 (mod 4) and 3 (mod 4)

4.3 Exercises on Linear Congruence Equations


1. Write down two linear congruence equations which do not have solutions.

2. Find all solutions of the following linear congruence equation 2x ≡ 5 (mod 7).

3. Find all solutions of the following linear congruence equation 6x ≡ 5 (mod 8).

4. Find all solutions of the following linear congruence equation 19x ≡ 30 (mod 40).

5. Find all solutions of the following linear congruence equation 15x ≡ 9 (mod 25).

6. Find all solutions of the following linear congruence equation 6x ≡ 3 (mod 9).

7. Find all solutions of the following linear congruence equation 14x ≡ 42 (mod 50).

8. Find all solutions of the following linear congruence equation 13x ≡ 42 (mod 50).

9. Find all solutions of the following linear congruence equation 15x ≡ 42 (mod 50).

10. Find all solutions of the following linear congruence equation 5x ≡ 22 (mod 84).

11. Find all solutions of the following linear congruence equation 980x ≡ 1540 (mod 1600).

12. Find all solutions of the following linear congruence equation 230 ≡ 1081 (mod 12167).
Chapter 5

The Chinese Remainder Theorem


(CRT)

5.1 Solved Problems


Problem 5.1.1. Find the smallest positive integer solution to the following system of
equivalences:

x ≡ 2 mod 5
x ≡ 5 mod 8
x ≡ 4 mod 37.

Solution. This is a direct application of the CRT: We have m1 = 5, m2 = 8, and m3 = 37.


Therefore

m1 · m2 · m3
M1 = = 296, so M1 ≡ 1 mod 5
m1
m1 · m2 · m3
M2 = = 185, so M2 ≡ 1 mod 8
m2
m1 · m2 · m3
M3 = = 40, so M3 ≡ 3 mod 37.
m3

We have
1 · 1 ≡ 1 mod 5, 1 · 1 ≡ 1 mod 8, 3 · 25 ≡ 1 mod 37.

So N1 = 1, N2 = 1, and N3 = 25. Thus

x = 2 · 296 · 1 + 5 · 185 · 1 + 4 · 40 · 25
= 5517
≡ 1077 mod 5 · 8 · 37.

An integer satisfies the system of congruences if and only if it is in this congruence class
modulo 5 · 8 · 37 = 1480. The smallest positive integers in this congruence class is 1077. 

23
24 CHAPTER 5. THE CHINESE REMAINDER THEOREM (CRT)

Problem 5.1.2. Find the smallest positive integer x satisfying the following system, or
show that no such x exists:

2x ≡ 1 mod 3
3x ≡ 2 mod 5
4x ≡ 3 mod 7
5x ≡ 4 mod 11.

Solution. Observe that

2−1 ≡ 2 mod 3, 3−1 ≡ 2 mod 5, 4−1 ≡ 2 mod 7, and 5−1 ≡ 9 mod 11.

Now, we multiply the first equation by 2−1 , the second by 3−1 , the third by 4−1 , and
the fourth by 5−1 . Then the system of equations become

x ≡ 2 mod 3
x ≡ 4 mod 5
x ≡ 6 mod 7
x ≡ 3 mod 11.

We solve this via the CRT: x ≡ 839 mod 1145. So the smallest positive solution is
x = 839. 

5.2 Exercises on the CRT


1. Solve the simultaneous system below.

x≡2 (mod 3)
x≡3 (mod 5)
x≡2 (mod 7).

2. Solve the simultaneous system below.

x≡1 (mod 4)
x≡2 (mod 3)
x≡3 (mod 5).

3. Solve the simultaneous system below.

x≡2 (mod 3)
x≡4 (mod 5)
x≡6 (mod 13).

4. Find an integer that leaves a remainder of 9 when it is divided by either 10 or 11,


but that is divisible by 13.
5.2. EXERCISES ON THE CRT 25

5. Solve the simultaneous system below.

4x ≡ 2 (mod 6)
3x ≡ 5 (mod 7)
2x ≡ 4 (mod 11).
26 CHAPTER 5. THE CHINESE REMAINDER THEOREM (CRT)
Chapter 6

Wilson’s Theorem

Lemma 6.0.1. Let p be a prime number and a ∈ Z. Then a is the solution of the linear
congruence ax ≡ 1 mod p if and only if a = 1 or a = p − 1.

Proof. Now we claim that If a = b, then a2 ≡ 1 mod p. This gives

p | a2 − 1 =⇒ p | (a − 1)(a + 1) =⇒ p | p − 1 or p | a + 1.

If p | a − 1, then a = 1. If p | a + 1, then a = p − 1. Thus we conclude that a = 1 or


a = p − 1.
Conversely, suppose that a = 1 or a = p − 1. If a = 1, then a2 ≡ 1 mod p. If a = p − 1,
then a2 = p2 +1−2p. Therefore a2 −1 = p2 −2p and so p | a2 −1. Hence a2 ≡ 1 mod p.

Theorem 6.0.2 (Wilson’s Theorem). If p is a prime number, then

(p − 1)! ≡ −1 mod p.

Proof. If p = 2, then it is obvious that (p − 1)! ≡ −1 mod p. Also if p = 3, then it is


obvious that (p − 1)! ≡ −1 mod p.
So, let us assume that p > 3. Let S = {1, 2, 3, . . . , p − 1} and a ∈ S. Clearly gcd(a, p) =
1. Consider the linear congruence ax ≡ 1 mod p. By Theorem, this congruence ax ≡
1 mod p admits a unique solution modulo p. This implies that there is a unique integer
b ∈ S such that ab ≡ 1 mod p.

2 · 3 · · · (p − 2) ≡ 1 mod p =⇒ (p − 2)! ≡ 1 mod p =⇒ (p − 1)! ≡ (p − 1) mod p.

Hence, since p − 1 ≡ −1 mod p, we conclude by transitivity that (p − 1)! ≡ −1 mod p.

6.1 Solved Problems


Problem 6.1.1. Find the remainder when 18! is divided by 437.

Solution. Note that 437 is not a prime, but 437 = 19 · 23. So we will consider 18! modulo
19 and modulo 23 separately.

27
28 CHAPTER 6. WILSON’S THEOREM

Since 19 is prime, a straightforward application of Wilson’s Theorem tells us that


18! ≡ −1 mod 19.
To compute 18! mod 23, we will also use Wilson’s Theorem, but we will have to work
a little bit harder. Wilson’s Theorem gives us that 22! ≡ −1 mod 23. Now

22! = 18! · 19 · 20 · 21 · 22
≡ 18! · (−4) · (−3) · (−2) · (−1) mod 23
≡ 18! · 24 mod 23
≡ 18! mod 23.

Therefore we have
18! ≡ 22! ≡ −1 mod 23.
In conclusion, 18! ≡ −1 mod 19 and 18! ≡ −1 mod 23. This yields 19 | 18! − (−1) and
23 | 18! − (−1). Since gcd(18, 23) = 1, we obtain (18 · 23) | 18! − (−1). This gives
18! ≡ −1 mod 437. Hence the answer is 436 which is indeed equal to −1 mod 437. 

6.2 Exercises on Multiplicative Inverse


1. Calculate 100−1 mod 2011. Answer: 181.
Chapter 7

Euler-Phi Functions

7.1 Solved Problems


Problem 7.1.1. Calculate φ(27).

Solution.
φ(27) = φ(33 ) = 32 · 2 = 18.

Problem 7.1.2. Calculate φ(1200).

Solution.

φ(1200) = φ(24 · 3 · 52 ) = φ(24 ) · φ(3) · φ(52 ) = 8 · 2 · 20 = 320.

Problem 7.1.3. Calculate φ(2008).

Solution.
φ(2008) = φ(23 · 251) = φ(23 ) · φ(251) = 4 · 250 = 1000.

Problem 7.1.4. Let n ∈ N and let p be a prime. If p | n, then show that φ(pn) =
(p − 1)φ(n).

Solution. Since p | n, the prime factorization of n is


mk
n = pm pm 1 m2
1 p2 . . . pk ,

where p1 , . . . , pk are primes and m1 , . . . , mk ∈ N. Thus


mk mk
φ(n) = φ(pm pm 1 m2 m m1 m2
1 p2 . . . pk ) == φ(p ) φ(p1 p2 . . . pk ).

29
30 CHAPTER 7. EULER-PHI FUNCTIONS

and hence
mk
φ(pn) = φ(pm+1 pm 1 m2
1 p2 . . . pk )
mk
= φ(pm+1 ) φ(pm 1 m2
1 p2 . . . pk )
mk
= (p − 1)φ(pm ) φ(pm1 m2
1 p2 . . . pk )
= (p − 1)φ(n).

7.2 Exercises on Euler Phi functions


1. Calculate φ(2010). Answer: 528
Bibliography

[1] J. B. Fraleigh, A First Course in Abstract Algebra, (Fifth Edition), Addison-Wesley,


1994.

[2] J. A. Gallian, Contemporary Abstract Algebra, (Third Edition), D.C. Heath, 1994.

[3] G. Birkhoff and S. MacLane, A Survey of Modern Algebra, A. K. Peters Ltd., 1997.

[4] I. N. Herstein, Topics in Algebra, (Second Edition), Blaisdell, 1975.

[5] G. D. Birkhoff and T. C. Bartee, Modern Applied Algebra, McGraw-Hill Book Com-
pany, 1970.

[6] L. Dornhoff and F. Hohn, Applied Modern Algebra, Macmillan, 1978.

[7] B. L. Van der Waerden, Modern Algebra, (Seventh Edition, 2 vols), Fredrick Ungar
Publishing Co., 1970.

[8] T. W. Hungerford, Algebra, Springer Verlag, 1980.

[9] N. Jacobson, Basic Algebra I and II, (Second Edition, 2 vols), W. H. Freeman and
Company, 1989.

[10] S. Lang, Algebra, Addison-Wesley, (Third Edition), 1992.

31
Index

Abelian group, 15
Associative operation, 6

Binary operation, 3

Cartesian product, 46
Cayley table, 5
Commutative group, 15
Commutative operation, 8
Commutative semigroup, 8
Conjugate elements, 64

External direct product of groups, 46

General linear group of degree n, 36


Group, 13
Groupoid, 4

Hamiltonion group, 32

Identity element, 11
Inverse element, 13

Klein’s four group, 30

Mixed group, 64
Monoid, 12
Multiplication table, 5

Periodic group, 64
Permutation, 33

Quaternion group, 32

Semigroup, 6
Symmetric group of degree n, 34

Torsion group, 64
Torsion-free group, 64
Transformation, 32
Trivial group, 14

32

You might also like