0% found this document useful (0 votes)
15 views

Number Theory Lecture Notes

These lecture notes cover various topics in number theory, including integers, divisibility, prime numbers, and theorems related to congruences. Key concepts such as the well ordering principle, pigeonhole principle, and mathematical induction are introduced, along with properties of sums and products. The document serves as a comprehensive guide for understanding foundational principles in number theory.

Uploaded by

mafabiesau4
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views

Number Theory Lecture Notes

These lecture notes cover various topics in number theory, including integers, divisibility, prime numbers, and theorems related to congruences. Key concepts such as the well ordering principle, pigeonhole principle, and mathematical induction are introduced, along with properties of sums and products. The document serves as a comprehensive guide for understanding foundational principles in number theory.

Uploaded by

mafabiesau4
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 54

Number Theory Lecture Notes 1

Contents
1 Integers 2
1.1 Algebraic operations with integers . . . . . . . . . . . . . . . . . . 2
1.2 The well ordering principle (WOP) . . . . . . . . . . . . . . . . . 3
1.3 The pigeonhole principle . . . . . . . . . . . . . . . . . . . . . . . 3
1.4 Principle of mathematical induction . . . . . . . . . . . . . . . . . 4
1.5 Sums and Products . . . . . . . . . . . . . . . . . . . . . . . . . . 5
1.5.1 Properties of sums and products . . . . . . . . . . . . . . . 5

2 Divisibility 6
2.1 Representation of integers in different bases . . . . . . . . . . . . 8

3 The greatest common divisor(GCD) 8


3.1 Euclidean Algorithm . . . . . . . . . . . . . . . . . . . . . . . . . 10

4 Prime numbers 12
4.1 Algorithm of the Sieve of Eratosthenes . . . . . . . . . . . . . . . 13
4.2 Least/lowest common multiple(LCM) . . . . . . . . . . . . . . . . 18
4.3 Fermat Numbers . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
4.4 Linear Diophantine equations (LDE) . . . . . . . . . . . . . . . . 21

5 The theory of congruences 25


5.1 Basic properties of congruences . . . . . . . . . . . . . . . . . . . 26
5.2 Binary and decimal representation of integers . . . . . . . . . . . 28
5.3 Linear congruences . . . . . . . . . . . . . . . . . . . . . . . . . . 31
5.4 Chinese Remainder Theorem . . . . . . . . . . . . . . . . . . . . . 33

6 Theorems of Fermat, Euler and Wilson 37

7 Number Theoretic Functions (Arithmetic functions) 43

8 Primitive Roots 46

9 Perfect numbers and Mersenne primes 50

10 Quadratic residues 51

11 Some special features in number theory 53

References 53
2 Abubakar Mwasa

1. Integers
“It takes a village to count integer points.”

Before we discuss integers, we explain what natural (whole) numbers are. Nat-
ural numbers are written using ten numerals 0, 1, 2, ... , 9, where the position of
the numeral dictates e.g. 1246 stands for 1 thousand, 2 hundreds, 4 tens and 6
units(ones). Here, numerals 1, 2, 4 and 6 are called the thousands, hundreds, tens
and unit coefficients. This is place value principle. A set of all natural numbers
is denoted by N = {0, 1, 2, ...}. Natural numbers can be represented by equally
space points on a straight line (number line) i.e.
fig 1

On the number line, numbers to the left of a given number are less than < the
given number and numbers to the right are greater than > the given number, i.e.
from above figure fig 1, a < b or b > a. If the number line in fig1 is extended to
the left of zero i.e.
fig 2

We obtain negative (−) of natural numbers. These negative and positive natural
numbers together with zero are called integers. The set of integers are denoted
by Z = Z+ ∪ {0} ∪ Z− , where Z+ = {1, 2, ...} and Z− = {... , −2, −1}.

1.1. Algebraic operations with integers


(a) Z is closed under addition, (+) and multiplication (·) i.e. if a, b ∈ Z then
a + b ∈ Z and a · b ∈ Z.
(b) Associativity property. If a, b, c ∈ Z, then (a + b) + c = a + (b + c) and
(a · b) · c = a · (b · c).
(c) Commutativity property. If a, b ∈ Z, then a + b = b + a and a · b = b · a.
(d) Distributivity property. If a, b, c ∈ Z, then a · (b + c) = a · b + a · c and
(a + b) · c = a · c + b · c.
(e) Additive identity. 0 ∈ Z. For all a ∈ Z, a + 0 = 0 + a = a.
(f) Every element has an additive inverse. If a ∈ Z, then there is an element
−a ∈ Z such that a + (−a) = (−a) + a = 0.
(g) Multiplicative inverse. There is a 1 ∈ Z such that for all a ∈ Z, a · 1 =
1 · a = a.
Number Theory Lecture Notes 3

(h) Suppose a, b ∈ Z and a ̸= 0, b ̸= 0 and a · b = 0, then either a = 0 or b = 0.


(i) Trichotomy. If a ∈ Z, either a < 0, a = 0 or a > 0.
Note that if a, b ∈ N, then exactly one of the following is true a = b, a < b and
b > a. If a = b or a < b holds, then a ≤ b or b ≥ a (less or equal; greater
or equal). The symbols ” <, >, ≤, ≥ ” are called inequalities. Inequalities are
transitive, i.e. if a < b and b < c, then a < c. The inequality b > a means that
b − a is a positive integer.

Example 1.1. If a ∈ Z, prove that −a = (−1) · a.


proof.

(−1) · a + a = (−1) · a + 1 · a multiplcative identity


= (−1 + 1) · a distributive property
=0·a=0

Example 1.2. Prove that if a > 0 and b < 0, then ab < 0.


Proof. Given that b < 0 and so 0 − b = −b ∈ Z+ . Also that a > 0, so
a = a − 0 ∈ Z+ . By closure, a · (−b) is positive integer (Z+ ) and so is −(a · b).
Thus, 0 − ab = −(ab) ∈ Z, implying 0 > ab.

1.2. The well ordering principle (WOP)


Every nonempty subset S ⊂ N(positive integers) contains a least element. A
least(smallest or minimal) element of a subset S ⊂ N is an element s0 ∈ S for
which s0 ≤ s for all s ∈ S. Similarly, a greatest or maximal element s∗ of S is
one for which s ≤ s∗ for all s ∈ S. Note that N has a least element 0, but has no
greatest element since for each n ∈ N, n + 1 ∈ N and n < n + 1.

Definition 1.3. A set S of real numbers is said to be well-ordered if every


nonempty subset of S has a smallest element.

It follows from WOP, that a set of positive integers N is well ordered. However,
rational numbers, Q, are not well-ordered. To see this, let x be the smallest
element in Q. Then x − 1 is a rational number that is smaller than x, which
contradicts the minimality of x. So the set Q does not have a smallest element,
thus it is not well-ordered.

1.3. The pigeonhole principle


If s objects are placed in k boxes for s > k, then at least one box contains more
than one object.

Proof. Suppose that none of the boxes contains more than one object. Then there
are at most k objects. A contradiction since there are s objects for s > k.
4 Abubakar Mwasa

1.4. Principle of mathematical induction


Let for each n ∈ N, the statement P (n) be defined. Then if
1. P (1) is true for all n ∈ N.
2. whenever P (k) implies P (k + 1) is true.
Then P (n) is true for all n ∈ N.
Proof. Let S be a set of positive integers (N) containing 1 and the integer k + 1
whenever k ∈ S. Assume also that S is not of all positive integers. Then some
integers are not in S and thus those integers must have a least element α by
WOP. Note that α ̸= 1 since 1 ∈ S. But α − 1 ∈ S and thus using the property
of S, α ∈ S. Implying that S contains all positive integers.
Example 1.4. Show that for all n ∈ N,
n
X n(n + 1)
k= .
k=1
2
Solution. Let n
X n(n + 1)
P (k) = k= .
k=1
2
1
X 1(2)
For n = 1, P (1) = k=1= = 1. True for n = 1.
k=1
2
n
X n(n + 1)
Suppose it holds for P (n) = k=
k=1
2
For
n+1 n
X X n(n + 1) 1
P (n + 1) = k= k + (n + 1) = + n + 1 = (n + 1)(n + 2).
k=1 k=1
2 2
Therefore P (n) holds for all n ∈ N.
Example 1.5. Prove that n! ≤ nn for all n ∈ Z+ .
Proof. For n = 1, 1! = 1 ≤ 1′ = 1. Suppose n! ≤ nn for some n.
We now show that (n + 1)! ≤ (n + 1)n+1 .
So
(n + 1)! = (n + 1)n! ≤ (n + 1) · nn < (n + 1) · (n + 1)n = (n + 1)n+1 .
∴ true for all n ≤ N.
Exercise 1.6. Prove the following for all n ∈ Z+
n
X n(n + 1)(2n + 1)
(a) k2 =
k=1
6
(b) n2 < n! for n ≥ 4.
Xn
(c) (2k − 1) = n2 .
k=1
Number Theory Lecture Notes 5

1.5. Sums and Products


We recall that the terms sum and product describe an addition and a multiplica-
tion relationship respectively. Addition and multiplication are binary operation,
i.e. they operate on two numbers (terms) at a time. Notation for sums and prod-
ucts. Consider a list of numbers {a1 , a2 , ... , an }.
Then a sum of n numbers
n
X
aj = a1 + a2 + ... + an .
j=1

and product of numbers


n
Y
aj = a1 a2 ... an .
j=1

1
X 1
Y
Thus for n = 1, aj = a1 ; aj = a1 .
j=1 j=1
2
X 2
Y
For n = 2, aj = a1 + a2 ; aj = a1 a2 .
j=1 j=1

1.5.1. Properties of sums and products


Let a, b, c ∈ Z+ . Then
X n n
X n
X n
Y n
Y n
Y
 
(a) (aj + bj ) = aj + bj ; aj b j = aj · bj .
j=1 j=1 j=1 j=1 j=1 j=1
Xn n
X n
Y n
Y
(b) c · aj = c aj ; c · aj = c aj .
j=1 j=1 j=1 j=1
n
X n
Y
(c) c = n · c; c = cn .
j=1 j=1
n n
Y Y k
(d) akj = aj .
j=1 j=1

Example 1.7. Find the following


4
X
(a) j 2 = 12 + 22 + 32 + 42 = 30.
j=1
50
X
(b) 4 = 50 · 4 = 200.
j=1
Y5
(c) en = e · e2 · e3 · e4 · e5 = e15 .
n=1
6 Abubakar Mwasa

20
Y
(d) 5 = 520 .
k=1

Note that if n ∈ Z+ , n! (n-factorial) is the product of integers from 1 to n, i.e.


Yn
n! = j = 1 · 2 · ... · n. By convention, 0! = 1! = 1.
j=1

Exercise 1.8. Compute


50
Y 4 4
(a) 1+ + 2
k=1
k k
X n
(b) (ai + c), where c is fixed.
i=1

2. Divisibility
In this section, we will discuss the concept of divisibility and its properties.

Definition 2.1. Let a, b be integers such that a ̸= 0. We say “a divides b” or “b


is divisible by a”, written a|b, if there exists an integer x such that b = xa.

If a divides b, we can also say “a is a factor (divisor) of b” or “b is a multiple


of a”. Any integer a has ±1 and ±a as trivial divisors. If a does not divide b, we
write a ∤ b, e.g. 2|4, 5|30 while 7 ∤ 20.

Proposition 2.2. Let a, b, c be integers.

(i) If a|b and b ̸= 0, then |a| ≤ |b|.

(ii) If a|b, then a|bc.

(iii) If a|b and b|c, then a|c.

(iv) If c|a and c|b, then c|(ax + by) for all x, y ∈ Z.

(v) If a|b and b|a, then a = ±b.

(vi) Assume c ̸= 0, then a|b if and only if ac|bc.

Proof. (iii) Since a|b and b|c, then there exist x1 , x2 ∈ Z such that b = x1 a and
c = x2 b. From which, we have that c = x2 x1 a. Thus a|c since x2 x1 is an
integer.

(iv) Since c|a and c|b, there exist x1 , x2 such that a = x1 c and b = x2 c. Thus
xa + yb = x1 xc + yx2 c = c(x1 x + yx2 ). Implying that c|(xa + yb).
Number Theory Lecture Notes 7

By the way, Proposition 2.2(iv) can be generalised to any finite linear combi-
nation, i.e. if
n
X
a|b1 , a|b2 , ... , a|bn , then a| kj bj for kj ∈ Z.
j=1

Theorem 2.3. [Division algorithm]. If a and b are integers such that b > 0, then
there exist unique integers q and r such that a = bq + r and 0 ≤ r < b.

Proof. Let S = {a − bk ≥ 0|k ∈ Z} ⊂ Z+ . S is nonempty since 0 ∈ S. By


Well ordering principle, S has a least element r = a − bq for some q ∈ Z+ .
Note that r ≥ 0 by construction, so if r ≥ b, then since b > 0, r > r − b =
a − bq − b = a − b(q + 1) ≥ 0. Contradiction since r is assumed to be the least
positive integer of the form r = a − bq. Thus 0 ≤ r < b. To prove uniqueness,
let a = bq1 + r1 and a = bq2 + r2 with 0 ≤ r1 < b and 0 ≤ r2 < b. Then
b(q1 − q2 ) + r1 − r2 = 0 or b(q1 − q2 ) = r2 − r1 . Implying that b|(r2 − r1 ).
Since − max{r1 , r2 } ≤ |r2 − r1 | ≤ max{r1 , r2 } and b > max{r1 , r2 }, we have that
r2 − r1 = 0 i.e. r2 = r1 . And since bq1 + r1 = bq2 + r2 , we get that q1 = q2 .

Example 2.4. If a = 71 and b = 6, then 71 = 6 · 11 + 5. Here q = 11 and r = 5.

Remark 2.5. Given that a, b ∈ Z such that a = bq + r, then


(a) b|a if and only if r = 0.
(b) the integer a is usually called the dividend, b is the divisor, q is the quotient
and r is the remainder.
(c) Every number divides 0.
(d) A 1 or −1 divides every number.
(e) Every number is divisible by itself.

Exercise 2.6. (a) Show that 19|38, 3|21 and 7 ∤ 30.


(b) Find q and r when −100 is divided by 13.
(c) Show that if a, b, c and d are integers with a ̸= 0 and c ̸= 0 such that a|b
and c|d, then ac|bd.

Example 2.7. Prove that if x is even, then x2 + 2x + 4 is divisible by 4.


Solution. x is even means 2|x. 4 = 2 · 2|x · 2 = x2 . Also 2|2 and 2|x, implying
4 = 2 · 2|2 · x = 2x. Thus 4|x2 + 2x + 4.

Example 2.8. Prove that if n ∈ Z, then n2 does not leave a r = 2 or 3 when


divided by 5.
Solution. If n is divided by 5, r satisfies 0 ≤ r < 5, thus r = 0, 1, 2, 3, 4. Hence,
n has one of forms 5q + 0, 5q + 1, 5q + 2, 5q + 3, 5q + 4.
8 Abubakar Mwasa

Checking each case, for

r = 0, n2 = (5q)2 = 25q 2 = 5(5q 2 ) + 0


r = 1, n2 = (5q + 1)2 = 5(5q 2 + 2q) + 1
r = 2, n2 = (5q + 2)2 = 5(5q 2 + 4q) + 4
r = 3, n2 = (5q + 3)2 = 5(5q 2 + 6q + 1) + 4
r = 4, n2 = (5q + 4)2 = 5(5q 2 + 8q + 3) + 1

For all cases, no r = 2 or 3.

2.1. Representation of integers in different bases


Theorem 2.9. Let b be a positive integer with b > 1. Then any positive integer
m can be written uniquely as

m = al bl + al−1 bl−1 + ... + a1 b + a0 where l ∈ Z+ , 0 ≤ aj < b,

for j = 0, 1, ... , l and al ̸= 0.

Example 2.10. (a) Expand 214 to 3.


Solution.

214 = 3(71) + 1
71 = 3(23) + 2
23 = 3(7) + 2
7 = 3(2) + 1
2 = 3(0) + 2

Now taking the remainders of division, we have that

(214)10 = (21221)3 .

(b) Find (364)7 into base 10.


Solution. (3 × 72 ) + (6 × 71 ) + (4 × 70 ) = 193.

Exercise 2.11. Convert (7482)10 to base 6.

3. The greatest common divisor(GCD)


Definition 3.1. The greatest common divisor (GCD) of two integers a, b both
not zero is the greatest integer c that divides both a and b.
Number Theory Lecture Notes 9

It is also called highest common factor (HCF). We denote the greatest common
divisor of two numbers a, b by (a, b). In some literature, you will find gcd(a, b).
Note that (0, 0) = 0. If c, c′ are two greatest common divisors of a, b, then c|c′
and c′ |c. Thus, we must have that c′ = ±c. So because of this, we take the
greatest common divisor as positive i.e. (a, b) = (|a|, |b|).
Example 3.2. Find
(a) (24, 18)
(b) (12, −15)
Solution. We list the factors of each integer and pick out the greatest common
that belongs to both.
factors of 24 = {1, 2, 3, 4, 6, 12, 24} and factors of 18 = {1, 2, 3, 6, 9, 18}. Observe
that the common divisors are {1, 2, 3, 6} and the greatest among them is 6. Thus,
(24, 18) = 6.
Check in a similar way that (12, −15) = 3.
The above way of finding the greatest common divisor becomes difficult once
the numbers are large. Thanks to Euclidean algorithm that saves us. We will
discuss it shortly.
Definition 3.3. Two integers a and b are relatively prime (coprime) if (a, b) = 1.
For instance, (3, 4) = (7, 9) = 1 are relatively prime. In fact, the following
simple result show that all consecutive integers are relatively prime.
Lemma 3.4. Every two consecutive positive integers are relatively prime.
Proof. Let n and n + 1 be consecutive positive integers. Let d = (n, n + 1). Thus,
d|n and d|n + 1, implying that n = dr and n + 1 = ds for some r, s ∈ Z. So
dr + 1 = ds or d(s − r) = 1. Now, because s − r is an integer, it implies that d|1,
i.e. d ≤ 1. Similarly, d ≥ 1 and so d = 1.
Theorem 3.5. If (a, b) = d, then (a/d, b/d) = 1.
Proof. Let k be a positive common divisor such that k|a/d and k|b/d. So there
exist m, n ∈ Z+ such that a/d = km and b/d = kn or a = kmd and b = knd.
Observe that kd is a common divisor of both a and b. And off course kd ≥ d
since k ∈ Z+ . But (a, b) = d, so the integer k must be 1 (k = 1).
The following result shows that the greatest common divisor of two integers
does not change when a multiple of one of them is added.
Theorem 3.6. Let a, b and k be integers. Then (a, b) = (a + kb, b).
Proof. Let d be a common divisor of a and b. By Proposition 2.2 (iv), d|(a + kb),
hence d is a divisor of a + kb. Now assume c is a common divisor of a + kb and b,
then by Proposition 2.2 (iv), we have that c|((a + kb) − kb) = a. Implying that
c is a common divisor of a and b.
10 Abubakar Mwasa

Example 3.7. (a) Prove that if n ∈ Z, then (3n + 4, n + 1) = 1.


Solution. From the theorem above,

(3n + 4, n + 1) = ((3n + 4) − 3(n + 1), n + 1) = (1, n + 1) = 1.

Since the only positive integer that 1 is 1.


(b) (4, 14) = (4, 14 − 3(4)) = (4, 2) = 2.

Theorem 3.8. [Bezout’s Identity] The greatest common divisor of two integers
a and b, not both zero is the least positive integer such that ma + nb = d for some
integers m and n.

Proof. First consider a set of all positive integer linear combinations of a and b.
Note that this set is nonempty since a = 1 · a +0 · b and b = 0 · a +1 · b. This means
that the set has a least element d = ma + nb for some m, n ∈ Z, by well ordering
principle. By the division algorithm theorem, we have a = dq + r, 0 ≤ r < d. or

r = a − dq = a − q(ma + nb) = (1 − qm)a − qnb,

i.e. r is a linear combination of a and b. Since 0 ≤ r < d and d is the least


element, then r = 0 and a = dq. Hence, d|a. Similarly, d|b. So d is a common
divisor of a, b which is divisible by all other common divisors, so it must be the
greatest common divisor of a, b.

Note that if (a, b) = 1, then there exist integers m and n such ma + nb = 1.

Definition 3.9. Let a1 , a2 , ... , an be integers not all 0. The greatest common
divisor of these integers is the greatest integer that divides all in the set, denoted
by (a1 , a2 , ... , an ). And they are mutually relatively prime if (a1 , a2 , ... , an ) = 1.

Exercise 3.10. (a) Find (−30, 95), (15, 35).


(b) Show that if m is a positive integer, then 3m + 2 and 5m + 3 are relatively
prime.

3.1. Euclidean Algorithm


Euclidean algorithm gives an efficient way of computing the greatest common
divisor of two numbers. Also provides a way of finding numbers a and b, such
that (x, y) = ax + by.
Let a, b ∈ Z be nonzero. Define n0 = a, d0 = b. Then recursively define nk
using the division algorithm.

nk−2 = qk−1 nk−1 + nk , where 0 ≤ nk < nk−1 .


Number Theory Lecture Notes 11

The inequality 0 ≤ nk < nk−1 indicates that n′k s form a decreasing sequence of
nonnegative integers, so the algorithm terminates.
Illustration. Set nk = rk . By applying division algorithm, we have that
r0 = r1 q1 + r2 , 0 ≤ r2 < r1 ,
r1 = r2 q2 + r3 , 0 ≤ r3 < r2 ,
...

rk−2 = rk−1 qk−1 + rk , 0 ≤ rk < rk−1


rk−1 = rk qk .
Note that we get a remainder 0 eventually since all the remainders are integers
and every remainder in the next step is less the remainder in the previous one.
Recall that if a, b are integers and a = bq + r, where q, r ∈ Z, then (a, b) =
(r, b). This follows from Theorem 3.6, we have (bq + r, b) = (b, r). Thus
(a, b) = (b, r2 ) = (r2 , r3 ) = ... = (rk , 0) = rk .
Example 3.11. (a) Find (1914, 899). Hence, express it in terms of two inte-
gers.
Solution.
1914 = 2(899) + 116
899 = 7(116) + 87
116 = 1(87) + 29
87 = 3(29) + 0
Therefore, (1914, 899) = 29. We now write 29 as a linear combination of
1914, 899 by a method of back substitution, treating rk′ s as if there were
variables. So
29 = 116 + (−1)87
= 116 + (−1)(899 − 7(116))
= 8(116) + (−1)899
= 8(1914 − 2(899)) + (−1)899
= 8 · 1914 + (−17)899
(b) Find (60, 84). Hence, find the integers x and y such that (60, 84) = 60x +
84y.
Solution.

84 = 1(60) + 24
60 = 2(24) + 12
24 = 2(12).
12 Abubakar Mwasa

Thus (60, 84) = 12.


Working backwards, 12 = 60 + (−2)24 = (−2)84 + 3(60). So x = 3 and
y = −2.
Exercise 3.12. (a) For each of the following pairs, find the greatest common
divisor. Hence, express each gcd as a linear combination of the two integers.
(i) (187, 102)
(ii) (4147, 10672)
(iii) (780, 150)
(b) Find (70, 98, 108).
(c) Let a and b be integers such that 364a + 277b = 1. Prove that one and only
one of a and b is positive and the other is negative.

4. Prime numbers
Every positive integer can be written uniquely as a product of prime numbers
e.g. 15 = 3 · 5, 60 = 22 · 3 · 5. Thus, they are building blocks of integers. So it is
worth wondering how primes are distributed among integers.
Definition 4.1. A positive natural number p ∈ N for which p > 1 whose only
integer factors are ±1 and ±p is a prime.
Alternatively, one defines it as an integer p > 1 that is only divisible by 1 and
itself. Otherwise such a natural number is called composite. Examples of primes
include 2, 3, 5, 7, 11, 13, 17 and so on. Note that apart from 2, all primes are odd
since every even integer is divisible by 2.
Lemma 4.2. Every integer greater than one has a prime divisor.

Proof. Suppose there is an integer greater 1 that has no prime divisors. Since the
set of integers with elements greater than 1 with no prime divisors is nonempty,
then by well ordering principle, there is a least positive integer n > 1 that has
no prime divisors. Thus n is composite since n|n. Hence, n = ab with 1 < a < n
and 1 < b < n. Note that a < n and as a result since n is the least, a must have
a prime divisor which also is a divisor of n, contradiction.

Theorem 4.3. If n is a composite integer, then n has a prime factor not exceeding

n.

Proof. Since n is a composite


√ integer, b ∈ Z with 1 < a ≤
√ then n = ab for some√a,√
√ Suppose that a > n, then n < a ≤ b and ab > n n = n. Therefore,
b < n.
a ≤ n. By Lemma 4.2, √ a must have a prime divisor a1 which is also a prime
divisor of n and a1 ≤ a ≤ n.
Number Theory Lecture Notes 13

4.1. Algorithm of the Sieve of Eratosthenes


ˆ List from 2 and n (test number). Note√that every composite integer less than
n must have a prime factor less
√ than n. Hence, strike off the multiples of
the primes that are less than n.

ˆ Strike off all multiples of 2 greater than 2 from the list.

ˆ strike off all multiples of the next prime from the list.

ˆ Repeat
√ until no more multiples are found of the prime integers that are less
than n.

Example 4.4. (a) Show that 127 is a prime number.


Solution.
√ We just need to check that 127 has a prime factor less or equal
to 127 ≈ 11.27. It is quite easy to see that 127 is not divisible by 2, 3, 5, 7
or 11. Thus 127 is a prime number.

(b) Use the Sieve of Eratosthenes to find all primes less


√ than 50.
Solution. The integer 50 has a prime factors ≤ 50 ≈ 7.07.

2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
50

After striking out the multiples of primes ≤ 50, we have that primes less
than 50 are

{2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47}.

Theorem 4.5. [Euclid]. There are infinitely many prime numbers

Proof. If to the contrary, there are only finitely many primes p1 , p2 , ... , pn . Check
for p1 p2 ... pn + 1. This is not divisible by any of the primes p1 , P2 , ... , pn since
it leaves a remainder of 1 when divided by any of them. By Lemma 4.2, every
number greater than 1 is divisible by a prime. Contradicting the assertion, so
there are infinitely many primes.

The next result reveals that primes are spaced irregularly.

Theorem 4.6. For each positive integer n, there exists n consecutive composite
integers.

Proof. Consider the sequence of integers

(n + 1)! + 2, (n + 1)! + 3, ... , (n + 1)! + n, (n + 1)! + n + 1.


14 Abubakar Mwasa

Note that every integer in the sequence is composite because k divides (n+1)!+k
if 2 ≤ k ≤ n + 1, by Proposition 2.2 (iv), i.e.
(n + 1)! + k = 1 · 2 · 3 · ... k(k + 1) ... n(n + 1) + k
= k(1 · 2 · 3 · ... (k − 1)(k + 1) ... n(n + 1)) + k
= k(1 · 2 · 3 · ... (k − 1)(k + 1) ... n(n + 1) + 1)

Thus one can produce any number of consecutive composite integers. Indeed
(n + 1)! + 2 is divisible by 2, 3 divides (n + 1)! + 3, and so on. For instance, if a
sequence of 4 consecutive composite integers is desired, then
5! + 2 = 122 = 2 · 61
5! + 3 = 123 = 3 · 41
5! + 4 = 124 = 4 · 31
5! + 5 = 125 = 5 · 25
Exercise 4.7. (a) Find the smallest five composite consecutive integers.
(b) Establish that the sequence
(n + 1)! − 2, (n + 1)! − 3, ... , (n + 1)! − (n + 1)
produces n consecutive composite integers for n > 2.
(c) Three integers p, p+2 and p+6 which are all prime are called prime triplets.
Find five sets of prime triplets.

(d) Let p be a prime. Prove that for each n > 1, n p is not a rational number.
(e) Prove that every prime of the form 3k + 1 is necessarily of the form 6m + 1
Remark 4.8. How are primes distributed? Are they evenly distributed or sparsely.
The prime number theorem (PNT) gives an asymptotic estimate π(n), which
is the number of primes that approximately equal to lnnn , i.e.
π(n)
lim = 1.
n→∞ n/ ln n

The prime number theorem was first conjectured by Legendre and Gauss. First
proofs were given by Hadamard and de La Vallel Poussin in 1896. Other proofs
by Atle Selberg and Paul Erdös were in the 1930s.
Example 4.9. Estimate the number of primes less than 1000000.
Solution. By PNT,
1000000
π(1000000) ≈ ≈ 72382.
ln(1000000)
The actual number of primes less than 1000000 is 78498.
Number Theory Lecture Notes 15

Special forms of primes are numbers written as a string of ones (1s). For
instance, 11, 111, 1111 and so on, called repunits, denoted Rn , where n represents
n
the number of digits. Here Rn = 10 9−1 . For Rn to be prime, n must be a prime
number. Though, this is not a sufficient condition since R5 = 11111 = 41 · 271
and R7 = 1111111 = 239 · 4649.
By the way, there are many unsolved problems about distribution of primes.
For instance, there are primes that come in pairs (2 units apart) such as 5 and
7, 11 and 13. they are called twin primes.
Here are some of the unsolved problems
(a) Two prime conjecture. Are there infinitely many twin (p, p + 2 both prime)
primes? The largest pair currently known was discovered in September
2016, and are
2996863034895 · 21290000 ± 1, with 388342 digits.
There are 808, 675, 888, 577, 436 twin prime pairs below 1018 , see [1].
(b) We first define what Fibonacci numbers are. The Fibonacci sequence is the
series of numbers where each number is the sum of the two preceding num-
bers. For example, 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, ..., are Fibonacci
numbers. Mathematically, expressed by the formula
xn = xn−1 + xn−2 (4.1)
Fibonacci numbers that are primes from the above list are 2, 3, 5, 13. Are
there infinitely many prime Fibonacci numbers?
(c) Mersenne prime conjecture. There are infinitely many Mersenne primes i.e.
primes of the form 2n − 1. Note that if 2n − 1 is prime, then n itself must
be prime. The largest known prime as of December 2020, discovered by
Patrick Laroche of the great internet Mersenne prime search (GIMPS) in
2018, is the 51st known Mersenne prime
p = 282589933 − 1 with 24862048 digits.
(d) Goldbach conjecture. This is a very famous open problem concerning
primes perceived by C. Goldbach. It asserts that G every even integer
can be written as a sum of two numbers that are either primes or 1. For
instance
2=1+1
4=2+2=1+3
6=3+3=1+5
8=3+5=1+7
10 = 5 + 5 = 3 + 7
12 = 5 + 7 = 1 + 11
14 = 3 + 11 = 7 + 7 = 1 + 13.
16 Abubakar Mwasa

And in fact if one takes integers ≥ 4, then the conjecture can be reformu-
lated as “ Every even integer greater 4 can be written as a sum of two odd
primes”. So far either a proof or a counter example has not been found.
(e) There are infinitely many primes of the form n2 + 1, n ≥ 1.
Euler encountered with a conjecture of his own; “Any even integer greater or
equal to 6 of the form 4n + 2 is a sum of two numbers each being either a prime
of the form 4n + 1 or 1.

Theorem 4.10. [Euclid]. Let p be a prime number and a, b ∈ N. If p|ab, then


p|a or p|b.

Proof. If p|a, we are done. If p ∤ a, then (p, a) = 1, since only 1 and p divide
p. Or (p, a) = p but the latter implies p|a, contradicting the assumption. Thus
(p, a) = 1. Let m, n ∈ Z be such that mp + na = 1. Then mpb + nab = b and so
p|b.

In general, if a prime p divides a product of integers a1 a2 ... an , then p|aj for


some j. This is proved by induction.

Theorem 4.11. [Fundamental Theorem of Arithmetic]. Every positive integer


different from 1 can be written uniquely as a product of primes.

Proof. If n is prime, then n itself is a product of primes with a single factor. If n


is composite, we use proof by contradiction. Suppose there is some integer that
cannot be written as a product of primes. Let n be the least such integer. Let
n = ab with 1 < a < n and a < b < n. So a and b are products of primes say a =
p1 p2 ... pr and b = q1 q2 ... qs for suitable primes pj , qj and n = ab = p1 ... pr q1 ... qs .
Contradiction.
For uniqueness. Suppose that n = p1 p2 ... pr = q1 ... qs for primes pj , qj satis-
fying
p1 ≤ p2 ≤ ... ≤ pr and q1 ≤ q2 ≤ ... ≤ qs .
Then pr |q1 ... qs and hence pr |qk for some k = 1, ... , s which implies

p1 ... pr−1 = q1′ ... qs−1



,

where q1′ ... qs−1



is q1 ... qs with qk omitted. continuing this way, we get down to
the case
1 = q1′′ ... qs−r
′′
for some primes qj′′ .
But this is only possible if s = r, i.e. there are n such primes. By considering the
sizes of the primes, we have

p1 = q1 , p 2 = q 2 , p r = qs .
Number Theory Lecture Notes 17

Corollary 4.12. Every natural number n ≥ 1 has a unique factorization

n = pr11 pr22 ... prkk

for each j, pj is a prime, 1 ≤ rj and 2 ≤ p1 < p2 < ... < pk .


Proposition 4.13. Let a, b ∈ N be nonzero with prime power factorization

a = pr11 pr22 ... prkk , b = ps11 ps22 ... pskk ,

where 0 ≤ rj and 0 ≤ sj . Then

(a, b) = pt11 pt22 ... ptkk , with tj = min{rj , sj }.

Proof. For each j, ptj |a and ptj |b, hence ptj |(a, b). Then pt11 ... ptkk |(a, b) by Theo-
rem 4.10. If
(a, b)
1 < m = t1 ,
p1 ... ptkk
then m|(a, b) and there is a prime q|m, hence q|a and q|b. This means that q = pl
for some l and so ptl l +1 |(a, b). But then prl l +1 |a and psl l +1 |b which is impossible.
Hence, (a, b) = pt11 ... ptkk .

Note that if n = pr11 pr22 ... prkk where all pj are distinct for 1 ≤ j ≤ k, one would
write as Y a
n= pj j .
∀pj

Example 4.14. Prime factorization of 120 is given by

120 = 2 · 2 · 2 · 3 · 5 = 23 · 3 · 5.

Theorem 4.15. [Dirichlet Theorem]. Given an arithmetic progression of terms


an + b, for n = 1, 2, ..., the series contains an infinite number of primes if a and
b are relatively prime.
The proof for the above theorem is beyond the scope of this course.
Lemma 4.16. If a and b are integers both of the form 4k + 1, then their product
ab is of the form 4k + 1

Proof. let a = 4k1 + 1 and b = 4k2 + 1, then

ab = (4k1 + 1)(4k2 + 1) = 16k1 k2 + 4k1 + 4k2 + 1 = 4(4k1 k2 + k1 + k2 ) + 1.

Theorem 4.17. There are infinitely many primes of the form 4n + 3, when n is
a positive integer.
18 Abubakar Mwasa

Proof. Suppose there are finitely many primes of the form 4n + 3, say p0 = 3,
p1 , p2 , ... pn . Let N = 4p1 p2 ... pn + 3. Note that any odd prime is of the form
4n + 1 or 4n + 3. So there exists at least one prime in N of the form 4n + 3
or else N is of the form 4n + 1. Note that if 3|N , then 3|(N − 3) and hence
3|4p1 ... pn which is impossible since pi ̸= 3 for every i. Hence, 3 ∤ N . Also other
primes p1 , p2 , ... , pn ∤ N because if pi |N , then pi |(N − 4p1 ... pn ) = 3. Hence none
of p0 , p1 , ... , pn divides N . Thus there are infinitely many primes of the form
4n + 3.

Exercise 4.18. (a) Find the prime factorization of 32, 900 and 221122.
(b) Show that there are infinitely many primes of the form 6k + 5.
(c) List the first 10 primes of the form 4n − 1.

4.2. Least/lowest common multiple(LCM)


Definition 4.19. The least common multiple (LCM) of two positive integers a,
b is the smallest positive integer that is a multiple of both a and b.

OR. It is the smallest positive integer divisible by both a and b. It is denoted


by [a, b], or ⟨a, b⟩. For instance, [3, 4] = 12, [5, 8] = 40. It is possible to find
[a, b] from prime factorization of the integers a and b, i.e. let a = pa11 ... pamn ,
b = pb11 ... pbmn . Then
max(a1 ,b1 ) max(a2 ,b2 )
[a, b] = p1 p2 ... pmax(a
m
n ,bn )
,

where max(a, b) is the maximum of the two integers a and b.

Lemma 4.20. If a and b are two real numbers, then

min(a, b) + max(a, b) = a + b

Proof. Assume without loss of generality that a ≥ b, then min(a, b) = b and


max(a, b) = a. The proof follows.

Theorem 4.21. Let a and b be two positive integers. Then

(i) [a, b] ≥ 0
ab
(ii) [a, b] = (a,b)

(iii) If a|m and b|m, then [a, b]|m.

Proof. (ii) Let a = pa11 ... pamn , b = pb11 ... pbmn .


min(a ,b ) min(a ,b ) min(a ,b )
Recall that (a, b) = p1 1 1 p2 2 2 ... pm n n and
Number Theory Lecture Notes 19

max(a1 ,b1 ) max(a2 ,b2 ) max(an ,bn )


[a, b] = p1 p2 ... pm . Then
max(a1 ,b1 )+min(a1 ,b1 )
[a, b](a, b) = p1 ... pmax(a
m
n ,bn )+min(an ,bn )

= pa11 +b1 ... pamn +bn by Lemma 4.20


= pa11 ... pamn pba
1
1
... pbmn
= ab.

(iii) Since a|m and b|m, then there exist x, y ∈ Z such that ax = m and by = m,
so that ax = m = by. In other words, b|ax. If (a, b) = d, then db |x so that db k1 = x
for some k1 ∈ Z. Hence,

m = ax = a(b/d)k = (ab/d)k
ab ab
i.e. d
|m and from Theorem 4.21 (ii) d
= [a, b].

Example 4.22. Given 36 and 90. Find [36, 90] and (36, 90).
Solution. Write 36 and 90 in terms of prime factors i.e. 36 = 22 · 32 and
90 = 2 · 32 · 5. Thus,

[36, 90] = 22 · 32 · 5 = 180 and (36, 90) = 2 · 32 = 18.

Note that 36 · 90 = 18 · 180 = 32400.


diag 3

Exercise 4.23. (a) Find [240, 610], [9780, 9234].


(b) Find the least common multiple and the greatest common divisor of 25 56 72 11
and 23 58 72 13.
(c) Show that every common multiple of two positive integers a and b is divisible
by [a, b].

4.3. Fermat Numbers


Fermat numbers are numbers of the form
n
Fn = 22 + 1, n ≥ 0.

Fermat thought that all Fn were prime, e.g. F0 = 3, F1 = 5, F2 = 17, F3 = 257,


F4 = 65537. However,Euler gave a counter example, for instance F5 is a composite
5
number, i.e. 641|F5 = 22 + 1. Note that 641 = 24 + 54 and 641 = 27 · 5 + 1.
20 Abubakar Mwasa

Now we have that 27 · 5 = 641 − 1, so (27 · 5)4 = (641 − 1)4 = 641x + 1, where x
is an integer. Also 54 = 641 − 24 , so
228 (641 − 24 ) = 641x + 1
641 · 228 − 232 = 641x + 1
232 + 1 = 641(228 − x),
which proves that 641|232 + 1. Actually, Fn , for 5 ≤ n ≤ 32 is composite.
Definition 4.24. A Fermat prime is a Fermat number which is prime.
It is still an open problem whether there are infinitely many Fermat numbers.
Surprisingly, Fermat primes arise in deciding whether a regular n-gon (convex
polygon with n equal sides) can be constructed with a compass and a straight
edge. Gauss showed that this can be constructed if and only if n is a power of
2 times a product of distinct Fermat primes. Here are some of the properties of
Fermat primes.
(a) If p is prime and p|Fn , then p = k · 2n+2 + 1 for some k ∈ Z.
4
Example 4.25. Check F4 = 22 + 1 = 65537 for primality.
Solution. Here n =√4, all primes are of the form k · 26 + 1 = 64k + 1. We
check for primes ≤ 65537 ≈ 256.
k 64k + 1 conclusion
1 65 Not prime
2 129 Not prime
3 193 prime, but 193 ∤ 65537
4 257 257 > 256
Therefore, 65537 must be prime.
(b) F0 F1 ... Fn−1 = Fn − 2 for n > 0.
This can be proved by induction. For n = 1, we have F0 = 3, F1 = 5, so
F0 = F1 − 2, true.
Take n > 0, let us assume that it is true for n. We now prove for n + 1.
F0 F1 ... Fn−1 , so F0 F1 ... Fn−1 Fn = (Fn − 2)Fn .
Now
n n n n+1 n+1
(Fn −2)Fn = (22 −1)(22 +1) = 22·2 −1 = 22 −1 = 22 +1−2 = Fn+1 −2
Also holds for n + 1. Thus, holds for all n > 0.
(c) If m ̸= n, (Fm , Fn ) = 1.
Proof. Let m < n or else switch. Let p be prime and p|Fm and p|Fn .
Also p|F0 F1 ... Fn−1 since m < n implies that Fm occurs in the product.
But Fn − 2 = F0 F1 ... Fn−1 , so 2 = Fn − F0 F1 ... Fn−1 . Since p|Fn − 2
and p|F0 F1 ... Fn−1 , then p|2, so p = 2. This is impossible since all Fn′ s
are odd. Implying there is no prime that divides both Fm and Fn , hence
(Fm , Fn ) = 1.
Number Theory Lecture Notes 21

Remark 4.26. Knowing that primes becomes scarce as the list of positive inte-
gers grows, any Mathematician would be happy if there is a formula that generate
all primes. Some Mathematicians tried on some quadratic polynomials, one of
such polynomial is f (n) = n2 +n+41, which did give primes for n = 0, 1, 2, ... , 39.
However, for n = 40, f (40) = 412 and for n = 41, f (41) = 41 · 43, not prime was
shown by Euler. But again f (42) = 1847 is prime.

4.4. Linear Diophantine equations (LDE)


Under this section, we discuss equations in two variables. The solution to these
equations are a set of integers. Roughly speaking, this equation represent a
straight line.
Definition 4.27. A linear equation of the form ax + by = c where a, b, c are
integers is called a linear diophantine equation.
The solution (x0 , y0 ) to the linear diophantine equation require that (x0 , y0 ) are
integers. The following result describes a case in which linear diophantine equa-
tion has a solution.
Theorem 4.28. The equation ax + by = c has integer solutions if and only if d|c
where d = (a, b). Furthermore, if the equation has one solution x = x0 , y = y0 ,
then there are infinitely many solutions and the solutions are given by
b a
x = x0 + t; y = y0 − t, where t ∈ Z.
d d
Proof. Suppose ax + by = c has a solution x, y ∈ Z. And since d|a and d|b, then
d|(ax + by) = c. Let us assume d|c, then by Theorem 3.8, there exists m, n ∈ Z
such that d = ma + nb. Also there exists k ∈ Z such that c = dk. Now we have
that
c = dk = (ma + nb)k = a(km) + b(nk).
Thus a solution for the equation ax + by = c is x0 = km, y0 = nk.
We prove that there are infinitely many solutions. Let x = x0 + db t, y = y0 − ad t.
Note that
b a
ax + by = a(x0 + t) + b(y0 − t) = ax0 + by0 = c.
d d
Since ax0 +by0 = c, we have that a(x−x0 )+b(y −y0 ) = 0 or a(x−x0 ) = b(y −y0 ).
Dividing both sides by d, we have ad (x − x0 ) = db (y0 − y). Since (a/d, b/d) = 1.
It follows that b/d|x − x0 i.e. there exists an integer t such that
b b
x − x0 = t or x = x0 + t.
d d
Similarly, a/d|y0 − y i.e. there exists t ∈ Z such that
a a
y0 − y = t or y = y0 − t.
d d
22 Abubakar Mwasa

Corollary 4.29. Let a, b, c ∈ Z with a, b ̸= 0. If (a, b) = 1, then the set of


solutions to the LDE ax + by = 1 is given by

x = rc + bt, y = sc − at,

where t ∈ Z is arbitrary and r, s satisfy ar + bs = 1.

Example 4.30. (a) Show that 3x + 6y = 7 has no integer solution.


Solution. From the equation, we have d = (3, 6) = 3. But 3 ∤ 7. Thus
3x + 6y = 7 has no solution.
(b) Solve 6x + 9y = 21.
Solution. Since (6, 9) = 3|21, there are infinitely many integer solutions.
We may scale down the equation 6x + 9y = 21 to 2x + 3y = 7.
By inspection, x0 = 2 and y0 = 1 is a particular solution. And note that
(2, 3) = 1. Hence, the general solution is x = 2 + 3t, y = 1 − 2t.
It is not obvious to guess a particular solution by inspection, so it is rather
vital to use Euclid algorithm.
(c) Find all integer solution of the equation 117x + 17y = 5.
Solution. Since (117, 17) = 1 and 1|5, the equation has solutions. Apply-
ing Euclidean algorithm;

117 = 17 · 6 + 15
17 = 15 · 1 + 2
15 = 2 · 7 + 1
2=1·2

Then working backwards

1 = 15 − 2 · 7 = 8 · 15 − 7 · 17 = 8 · 117 + (−55)17.

So x0 = 8, y0 = −55 for 117x + 17y = 1.


Thus particular solution for 117x + 17y = 5 is (x1 , y1 ) = (5 · 8, 5 · −55) =
(40, −275). So the general solution (x, y) = (40 + 17t, −275 − 117t), t ∈ Z.
(d) Describe the set of solutions of the LDE 313x + 510y = 2.
Solution. Observe that (313, 510) = 1 and 1|2. By Euclidean Algorithm,
you get that

(−233)313 + (143)510 = 1, with r = −233, s = 143.

Thus, the general solution is x = 2(−233) + 510t, y = 2(143) − 313t or


x = −466 + 510t, y = 286 − 313t.
(e) Case Clinic Theatre charges shs.180000 for adult admissions and shs.75000
for children. On a particular evening the total receipts were shs.9, 000, 000.
Assuming that more adults that more adults than children were present,
Number Theory Lecture Notes 23

how many people attended?


Solution. Let x be the number of adults admitted and y be the number
of children. We solve

180000x + 75000y = 9000000 or 180x + 75y = 9000

For nonnegative integers x > y. By Euclidean Algorithm gives (75, 180) =


15 and that 5 · 75 + (−2)180 = 15. So that the general solution is
9000 75 9000 180
x = (−2) + t; y = (5) − t or x = −1200+5t ≥ 0, y = 3000−12t ≥ 0.
15 15 15 15
Putting the inequalities together yields

240 ≤ t ≤ 250 (4.2)

But x > y, so −1200 + 5t > 300 − 12t or t > 247.05. So from (4.2),
248 ≤ t ≤ 250 or t = {248, 249, 250}. Thus, the possible solutions are for

t = 248; x = 40, y = 24
t = 249; x = 45, y = 12
t = 250; x = 50, y = 0
(f) Shakira buys large blouse for shs.18000 and a small one at shs.11000. The
blouses cost a total of shs.118000. What is the smallest total number of
blouses she could have bought.
Solution. Let x be the number of large blouses and let y be the number of
small blouses. Then 18000x + 11000y = 118000 or 18x + 11y = 118. Since
(18, 11) = 1|118, there are solutions.
Using Euclidean Algorithm, check that 18(−3) + 11 · 5 = 1. And 18 ·
(−354) + 11 · 590 = 118. Thus x = −354, y = 590 is a particular solution.
The general solution is x = −354 + 11t, y = 590 − 18t. Since x ≥ 0, y ≥ 0
(number of blouses has to be positive),
So −354+11t ≥ 0 or t ≥ 254/11 ≈ 32 and 590−18t ≥ 0 or t ≤ 590/18 ≈ 33,
i.e. 32 ≤ t ≤ 33.
Total number of blouses x + y = (−354 + 11t) + (590 − 18t) = 236 − 7t.
For 32 ≤ t ≤ 33, the smallest for t = 33, we have that y = 0, x = 5 and
x + y = 5. So she bought 5 large blouses, no small blouses and a total of 5
blouses.
The results can be extended to linear Diophantine equations with more than
two variables. That is, let a1 , a2 , ... , an be nonzero integers. Then the linear Dio-
phantine equation a1 x1 + ... + an xn = c has a solution if and only if (a1 , ... , an )|c.
Furthermore, if the equation has at least one solution, then it is infinitely many
solutions.
Example 4.31. Find all integer solutions of the linear Diophantine equation
24 Abubakar Mwasa

(i) 3x − 6y + 5z = 4,
(ii) 8x + 14y + 5z = 11
Solution.
(i) The equation 3x − 6y + 5z = 4 has solutions since (3, −6, 5) = 1|4.
Now let k = −6y + 5z
3x + k = 4 (4.3)
By inspection, we see that (x, k) = (1, 1) is one particular solution of the
equation (4.3). And the general solutions of (4.3) are x = 1 + t, k = 1 − 3t,
t ∈ Z. Observe that
−6y + 5z = 1 − 3t (4.4)
And y0 = z0 = −1 + 3t is one solution of equation 4.4. (Generally speaking,
one would find a particular solution in the form y0 = a0 +a1 t, z0 = b0 +b1 t).
Thus, we conclude that all solutions (x, y, z) of 3x − 6y + 5z = 4 are given
by x = 1 + t, y = −1 + 3t + 5u, z = −1 + 3t + 6u, t, u ∈ Z.
(ii) Let 2(4x + 7y) + 5z = 11, and 2w + 5z = 11 where w = 4x + 7y. By
Euclidean Algorithm (EA),
1 = 5 + (−2)2 and so
11 = 11 · 5 + (−22) · 2
The particular solution to 2w + 5x = 11 is w0 = −22 and z0 = 11 and the
general solution w = −22 + 5s and z = 11 − 2s so
4x + 7y = w = −22 + 5s,
4x + 7y = −22 + 5s by EA
7=1·4+3
4 = 1 · 3 + 1 by back substitution
1 = 2 · 4 + (−1)7
multiplying through by −22 + 5s, we get
−22 + 5s = (−44 + 10s) · 4 + (22 − 5s) · 7
and so x = −44 + 10s, y = 22 − 5s
Thus, the general solution is x = −44+10s+7t, y = 22−5s−4t, z = 11−2s.
Example 4.32. A farmer wishes to buy 100 animals and spend exactly $100.
Cows are $10, sheep $3 and rabbits $0.50. Is this possible?
Solution. Let c represent cows, s for sheep and r for rabbits.
c + s + r = 100 (4.5)
10c + 3s + 0.50r = 100 (4.6)
Making r the subject in (4.5) and substituting in equation (4.6), we have that
19c + 5s = 100
Number Theory Lecture Notes 25

Observe that (19, 5) = 1|100, the equation has infinitely many solutions. Check
that 100 = 19(−100) + 5(400). Hence c = −100, s = 400 is a particular solution.
And the general solution is c = −100 − 5t, s = 400 + 19t. Since we need c, r, s to
be positive, we have that −100 − 5t ≥ 0 and 400 + 19t ≥ 0. −20 > t and −21 ≤ t
or −21 ≤ t ≤ 20. Thus t = −21 gives the unique solution in the positive integers
i.e. c = 5, s = 1, r = 94.

Exercise 4.33. (a) Either find all the solutions or prove that there are no
solutions for
(i) 21x + 7y = 147
(ii) 2x + 13y = 31
(iii) 2x + 14y = 17
(b) Find the integers x, y and z that satisfy
(i) 6x + 15y + 20z = 1
(ii) 8x + 14y + 5z = 11

5. The theory of congruences


Another approach to divisibility questions is through the arithmetic of remainders
or the theory of congruences. Congruence is nothing but a refined statement
about divisibility. They provide us with an algebraic machinery for the study
of divisibility properties of integers. The theory of congruences was introduced
by the German mathematician, Carl Friedrich Gauss (1777 – 1855), in his work
Disquisitiones Arithmeticae from 1801.
“Mathematics is the Queen of sciences, the theory of numbers is the Queen of
Mathematics”, Gauss.

Definition 5.1. Let n be a fixed positive integer. Two integers a and b are said
to be congruent modulo n, denoted by a ≡ b(mod n) if n divides the difference
a − b, i.e. a − b = kn for all k ∈ Z.

Illustration; if n = 7, then 3 ≡ 24(mod 7), −31 ≡ 11(mod 7) because 3 − 24 =


−21 = (−3)7 i.e. 7 | (3 − 24). Otherwise, if n ∤ (a − b), then a is incongruent to
b modulo n, usually written as a ̸≡ b(mod n).
If a ≡ b(mod n), then a and b leave the same remainder when divided by n.
If n = 0, then a ≡ b(mod n) implies a = b and for each of the integers a and
b, a ≡ b(mod 1). For instance, −56 ≡ −11(mod 9). But −56 = (−7)9 + 7 and
−11 = (−2)9 + 7 i.e. they have the same remainder 7.
26 Abubakar Mwasa

5.1. Basic properties of congruences


Let n > 1 be fixed and a, b, c, d be arbitrary integers. Then
(a) a ≡ a(mod n)
(b) If a ≡ b(mod n), then b ≡ a(mod n).
(c) If a ≡ b(mod n) and b ≡ c(mod n), then a ≡ c(mod n).
(d) If a ≡ b(mod n) and c ≡ d(mod n), then a ± c ≡ b ± d(mod n) and ac ≡
bd(mod n).
(e) If a ≡ b(mod n), then a + c ≡ b + c(mod n) and ac ≡ bc(mod n)
(f) If a ≡ b(mod n), then ak ≡ bk (mod n) for any positive integer k.
Proof. (a) For any integer a, a − a = 0 · n, so a ≡ a(mod n).
(b) If a ≡ b(mod n), then a − b = kn for k ∈ Z. Thus, b − a = −(kn) = (−k)n.
The proof follows since −k is an integer.
(c) We have that a − b = kn and b − c = hn for k, h ∈ Z. It follows that
a − c = (a − b) + (b − c) = kn + hn = (k + h)n and so a ≡ c(mod n) since
k + h is an integer.
(d) We have that a − b = k1 n and c − d = k2 n for k1 , k2 ∈ Z.
Now (a − b) + (c − d) = (k1 + k2 )n, from which we get (a + c) − (b + d) =
(k1 + k2 )n. Thus, a + c ≡ b + d(mod n).
While ac = (b + k1 n)(d + k2 n) = bd + kn where k = bk2 + dk1 + k1 k2 n is an
integer. Thus ac ≡ bd(mod n).
(e) This property is implied since c ≡ c(mod n).
(f) This follows from induction, for k = 1, a ≡ b(mod n). For fixed k, ak ≡
bk (mod n).
For k + 1, aak ≡ bbk (mod n) or ak+1 ≡ bk+1 (mod n).

Proposition 5.2. The relation “congruence modulo n” is an equivalence relation


on the set Z.
Proof. Reflexivity, symmetry and transitivity is all we need to examine. See
proofs of (a), (b) and (c) above, respectively.
Example 5.3. Find the remainder when the sum
(a) S = 1! + 2! + 3! + ... + 10000! is divided by 4.
(b) S = 1! + 2! + 3! + ... + 100! is divided by 12.
Solution.
(a) Since k! is divisible by 4 for all k ≥ 4.
S = 1! + 2! + 3! + ... + 10000!
≡ 1! + 2! + 3!(mod 4)
S ≡ 1 + 2 + 6 = 1(mod 4)
Remainder is 1, when S is divided by 4.
Number Theory Lecture Notes 27

(b) Through observation 4! = 24 ≡ 0(mod 12) for k ≥ 4.


k! ≡ 4! · 5 · 6 ... k ≡ 0 · 5 · 6 ... k ≡ 0(mod 12)
Thus,

1! + 2! + ... + 100! ≡ 1! + 2! + 3! + 0 + ... + 0 ≡ 9(mod 12),

i.e. S leaves a remainder of 9 when divided by 12.

Example 5.4. (a) Show that 41 divides 220 − 1.


(b) What is the remainder when 548 is divided by 12.

Solution.
(a) Note that 25 ≡ −9(mod 41) and so (25 )4 ≡ (−9)4 (mod 41) by property (f),
i.e. 220 ≡ 81 · 81(mod 41), but 81 ≡ −1(mod 41). Implying that 81 · 81 ≡
1(mod 41). Thus 220 − 1 ≡ 1 − 1 ≡ 0(mod 41), i.e. 41 | 220 − 1.
(b) 548 = (52 )24 = (25)24 ≡ (1)24 (mod 12). Thus 548 ≡ 1(mod 12) and the
remainder is 1.
Recall that if ab = ac for integers a, b, c, then b = c. But we cannot have
4 ≡ 10(mod 6) giving 2 ≡ 5(mod 6) since 6 ∤ (5 − 2) = 3. The following theorem
shows when such a cancellation is allowed in congruences.

Theorem 5.5. If ca ≡ cb(mod n), then a ≡ b(mod n/d), where d = (c, n).

Proof. By hypothesis, c(a − b) = ca − cb = kn for some integer k. Knowing that


(c, n) = d, then c = dr and n = ds for relatively prime integers r and s. So
dra − drb = kds or r(a − b) = ks, hence s | r(a − b) and (r, s) = 1. And s|(a − b)
by Euclid’s lemma. or a ≡ b(mod s), so a ≡ b(mod n/d).

Corollary 5.6. If ca ≡ cb(mod n) and (c, n) = 1, then a ≡ b(mod n).

Corollary 5.7. If ca ≡ cb(mod p) and p ∤ c, where p is a prime number, then


a ≡ b(mod p).

Proof. The conditions p ∤ c and p prime imply that (c, p) = 1.

Exercise 5.8. (a) Prove that


(i) If a ≡ b(mod n) and m|n, then a ≡ b(mod m).
(ii) If a ≡ b(mod n) and c > 0, then ca ≡ cb(mod cn).
(iii) If a ≡ b(mod n), then (a, n) = (b, n).
(b) Find the remainders when 250 and 4165 are divided by 7.
(c) Prove that the integer 53103 + 10353 is divisible by 39.
(d) Use congruence theory to establish each of the following;
(i) 7 | 52n + 3 · 25n−2
28 Abubakar Mwasa

(ii) 13 | 3n+2 + 42n+1


(iii) 89 | 244 − 1
(iv) 97 | 248 − 1
(e) Find the remainder when 214 is divided by 17, 3100 is divided by 5.
Proposition 5.9. A number n ∈ Z is divisible by 3 if and only if the sum of the
digits of n is divisible by 3.

Proof. Let n = a + 10b + 100c + .... Since 10 ≡ 1(mod 3) implies that

n = a + 10b + 100c + ... ≡ a + b + c + ... (mod 3).

Example 5.10. Find the remainder when 1135 is divided by 13.


Solution. Note that 1135 = (113 · 114 )5 . Moreover, 113 ≡ 5(mod 13) and
114 ≡ 3(mod 13).
By Property (d), we have

113 · 114 ≡ 5 · 3(mod 13) = 15(mod 13).

But 15 ≡ 2(mod 13) so 113 · 114 ≡ 2(mod 13) and (113 · 114 )5 ≡ 25 (mod 13).
Therefore 1135 ≡ 6(mod 13), since 25 ≡ 6(mod 13). Hence, the remainder is
6.

5.2. Binary and decimal representation of integers


We recall, for a fixed integer n > 1, any positive integer x can be written uniquely
in terms of powers of n as

x = am nm + am−1 nm−1 + ... + a2 n2 + a1 n + a0 ; a ≤ ai < n.

And that this number x can be replaced with x = (am am−1 ... a2 a1 a0 )n . For
instance, if x = 105 and n = 2, then

x = 1 · 26 + 1 · 25 + 0 · 24 + 1 · 23 + 0 · 22 + 0 · 2 + 1, unique representation

and x = 105 = (1101001)2 in binary form. Also,

(1001111)2 = 1·26 +0·25 +0·24 +1·23 +1·22 +1·2+1 = 64+0+0+8+4+2+1 = 79

Suppose we wish to calculate the value of ak (mod n) when k is large. Then write
j
k in binary form as k = (am am−1 ... a1 a0 )2 and the values a2 (mod n), 0 ≤ j ≤ m,
are calculated for the powers of 2, which correspond to the 1′ s in the binary
representation.
Number Theory Lecture Notes 29

Example 5.11. Calculate 5110 (mod 131)


Solution. First, convert 110 to binary base as follows

110 = 1 · 26 + 1 · 25 + 0 · 24 + 1 · 23 + 1 · 22 + 1 · 2 + 0 = (1101110)2
j
Thus, we obtain powers 52 for 0 ≤ j ≤ 6 by repeatedly squaring while at each
stage reducing each result modulo 131, i.e.

52 ≡ 25(mod 131)
54 ≡ 101(mod 131)
58 ≡ 114(mod 131)
516 ≡ 27(mod 131)
532 ≡ 74(mod 131)
564 ≡ 105(mod 131)

Thus,

5110 = 564+32+8+4+2
= 564 · 532 · 58 · 54 · 52
≡ 105 · 74 · 114 · 101 · 25(mod 131)
≡ 41 · 117 · 25(mod 131)
≡ 60(mod 131)

Note that 564 · 532 = 596 ≡ 105 · 74(mod 131) ≡ 41(mod 131) and 58 · 54 = 512 ≡
114 · 101(mod 131) ≡ 117(mod 131)
Example 5.12. Find 1135 (mod 13).
Solution.

35 = 1 · 25 + 0 · 24 + 0 · 23 + 0 · 22 + 1 · 2 + 1 = (100011)2
j
Implying that 35 = 32 + 2 + 1 and now for 112 (mod 13) for 0 ≤ j ≤ 5.

11 ≡ 11(mod 13)
112 ≡ 4(mod 13)
114 ≡ 3(mod 13)
118 ≡ 9(mod 13)
1116 ≡ 3(mod 13)
1132 ≡ 9(mod 13)

Thus, 1135 = 1132+2+1 ≡ 9 · 4 · 11(mod 13) ≡ 6(mod 13).


30 Abubakar Mwasa

Exercise 5.13. Compute (i) 1953 (mod 503), (ii) 14147 (mod 1537) (iii) 5113 (mod 131).
m
X
Theorem 5.14. Let P (x) = ck xk be a polynomial function of x with integral
k=0
coefficients ck . If a ≡ b(mod n), then P (a) ≡ P (b)(mod n).

Proof. Since a ≡ b(mod n), apply property (f) iteratively for k = 1, 2, ... , m to
get
a ≡ b(mod n), a2 ≡ b2 (mod n), ... , am ≡ bm (mod n).
Thus, cj aj ≡ cj bj (mod n) for j = 0, 1, 2, ... , m and finally,
m
X m
X
k
ck a ≡ ck bk (mod n) i.e. P (a) ≡ P (b)(mod n).
k=0 k=0

If P (x) is a polynomial with coefficients, we say that a is a solution of the


congruence P (x) ≡ 0(mod n) if P (a) ≡ 0(mod n).
Corollary 5.15. If a is a solution of P (x) ≡ 0(mod n) and a ≡ b(mod n), then
b is also a solution.
The theory of congruences enable us to perform tests of divisibility in a simpler
manner, without explicit division, but only on the basis of properties of digits of
the number in question.
Theorem 5.16. Let

x = am 10m + am−1 10m−1 + ... + a1 10 + a0

be the decimal expansions of the positive integer x, 0 ≤ ak < 10, and let S =
a0 + a1 + ... + am . Then 9|x if and only if 9|S.
m
X
Proof. Consider P (x) = ak xk , a polynomial with coefficients ak for k =
k=0
0, 1, ... , m. Observe that 10 ≡ 1(mod 9). Thus by Theorem 5.14, P (10) ≡
P (1)(mod 9). But P (10) = x and P (1) = a0 + a1 + ... + am = S. So that
x ≡ S(mod 9). It follows that x ≡ 0(mod 9) if and only if S ≡ 0(mod 9).

Theorem 5.17. Let N = am 10m + am−1 10m−1 + ... + a1 10 + a0 be the decimal


expansion of N > 0, 0 ≤ ak < 10 and let T = a0 − a1 + a2 − ... + (−1)m am . Then
11|N if and only if 11|T .

Proof. Because 10 ≡ −1(mod 11), we get P (10) ≡ P (−1)(mod 11). But P (10) =
N and P (−1) = a0 − a1 + ... + (−1)m am = T . So N ≡ T (mod 11). Thus either
11|N and 11|T or 11 ∤ N and 11 ∤ T .
Number Theory Lecture Notes 31

Example 5.18. Consider the integer N = 1571724. We see that S = 1 + 5 + 7 +


1 + 7 + 2 + 4 = 27, and 9|27. Thus, 9|1571724.
Also, 4 − 2 + 7 − 1 + 7 − 5 + 1 = 11, in the reverse order. So 11|11, implying
that 11|1571724.

Example 5.19. Given f (x) = x5 − 10x + 7. Find the remainder of f (27) when
divided by 5.
Solution. Note that 27 ≡ 2(mod 5). By Theorem 5.14, f (27) ≡ f (2)(mod 5).
Also, 10 ≡ 0(mod 5) and 7 ≡ 2(mod 5), so that

f (27) ≡ f (2)(mod 5)
≡ 25 − 10 · 2 + 7
≡ 25 − 0 · 2 + 2
≡ 34 ≡ 4(mod 5)

Since 0 ≤ 4 < 5, then 4 is a remainder of f (27) when divided by 5.

Exercise 5.20. (a) Show that


(i) 176521221 is divisible by 9
(ii) 670040107 is divisible by 11
(b) Find the remainder when 44444444 is divided by 9. (Hint 23 ≡ −1(mod 9)).
(c) Find the last decimal digit of 30799 . (Hint. Use mod 10).

5.3. Linear congruences


An expression of the form

ax ≡ b(mod n), a ̸= 0(mod n) (5.1)

is called a linear congruence modulo n. By solution of this congruence, we mean


an integer x0 such that ax0 ≡ b(mod n) if and only if n|ax0 − b or ax0 − b = ny0
or ax0 − ny0 = b for some integer y0 . Moreover, (x0 , y0 ) is a solution of the linear
diophantine equation
ax − ny = b (5.2)
We know that equation (5.2) has a solution if d = (a, n) divides b. If (x0 , y0 ) is a
particular solution, then any other solution is given by
n a
x′ = x0 + t, y ′ = y0 + t, t ∈ Z.
d d
Thus, x′ = x0 + nd t, t ∈ Z are all solutions of (5.1). But then
n
x0 + d ≡ x0 (mod n).
d
32 Abubakar Mwasa

In fact,
n n
x0 + (d + k) ≡ x0 + k(mod n); 0 ≤ k < d.
d d
Therefore, x0 , x0 + nd , ... , x0 + n(d−1)
d
are solutions of equation (5.1). The
argument leads to the following theorem.

Theorem 5.21. The linear congruence ax ≡ b(mod n) has a solution if and only
if d|b where d = (a, n). If d|b, then it has d mutually incongruent solutions modulo
n.

Proof. As observed above, ax ≡ b(mod n) has a solution equivalent to the dio-


phantine equation ax − ny = b which has a solution if d = (a, n), d|b.
Also if (x0 , y0 ) is a solution of equation (5.2), then x0 is a solution of ax ≡
b(mod n) and
n 2n (d − 1)
x0 , x0 + , x0 + , ... , x0 + n
d d d
are all solutions of ax ≡ b(mod n).
Further, if x0 + nd t1 ≡ x0 + nd t2 (mod n), 1 ≤ t1 , t2 < d. Then we would have
n
t ≡ nd t2 (mod n) or t1 ≡ t2 (mod d), since ( nd , n) = nd . Implying that d|t2 − t1 .
d 1
But this is impossible in view of the inequality 0 < t2 − t1 < d.
Thus, x0 , x0 + nd t, ... , x0 + (d−1)
d
n are mutually incongruent solutions of ax ≡
b(mod n).

Suppose x′ is any other solution of ax ≡ b(mod n), then ax′ ≡ b(mod n). Also
ax0 ≡ b(mod n).
ax′ ≡ ax0 (mod n) (5.3)
If a = dr, n = ds, with (r, s) = 1. Then drx′ ≡ drx0 (mod n) by equation (5.3).
Implying ds = n|(drx′ − drx0 ) or s|r(x′ − x0 ) or s|x′ − x0 or x′ = x0 + hs, h ∈ Z.
By division algorithm,
h = dq + t, 0 ≤ t < d. So x′ = x0 + dqs + ts = x0 + nq + nd t. Thus, x′ ≡
x0 + nd t(mod n).
Therefore, the congruence ax ≡ b(mod n) if admits a solution x0 , has d and
only d mutually incongruent solutions x0 , x0 + nd , x0 + 2n
d
, ... , x0 + nd (d−1)(mod n).

Corollary 5.22. The linear congruence ax ≡ b(mod n) has a unique solution if


and only if (a, n) = 1.

Remark 5.23. Given (a, n) = 1, then the congruence ax ≡ 1(mod n) has a


unique solution called the multiplicative inverse of a modulo n.

Example 5.24. Solve 18x ≡ 30(mod 42).


Number Theory Lecture Notes 33

Solution. Since (18, 42) = 6 and surely 6|30. Theorem 5.21 guarantees the
existence of exactly 6 solutions, which are incongruent modulo 42. By inspection,
x0 = 4,
Other solutions are
42
x ≡ 4 + t ≡ 4 + 7t(mod 42), t = 0, 1, ... , 5.
6
i.e. x = 4, 11, 18, 25, 32, 39.
Example 5.25. Solve the linear congruence 9x ≡ 21(mod 30).
Solution. (9, 30) = 3 and 3|21. The equivalent linear Diophantine equation
is 9x − 30y = 21.
And from Euclidean Algorithm, check that 9(−21) − 30(−7) = 21. Thus
x0 = −21 and y0 = −7. Therefore, solutions to the congruence equation are
30
x = −21 + t = −21 + 10t, t = 0, 1, 2.
3
And x ≡ −21(mod 30), x ≡ −11, −1 or x ≡ 9, 19, 29(mod 30).
Example 5.26. Solve the linear congruence 6x ≡ 15(mod 21).
Solution. Since (6, 21) = 3 and 3|15, then the congruence has a solution.
Taking x0 = 6, as a solution of 6x ≡ 15(mod 21). Other solutions are x ≡ 6 + 21
3
t,
t = 0, 1, 2. Therefore, x ≡ 6, 13, 20.
Exercise 5.27. Solving the following congruences
(a) 25x ≡ 15(mod 29)
(b) 140x ≡ 133(mod 301)
(c) 5x ≡ 2(mod 26)
(d) 99x ≡ 100(mod 101)
Having considered a single linear congruence, it is natural to turn to the
problem of solving a system of simultaneous linear congruences i.e.
a1 x ≡ b1 (mod n1 ), a2 x ≡ b2 (mod n2 ), ... , ar x ≡ br (mod nr )
where ni , i = 1, 2, ... , r are relatively prime in pairs.

5.4. Chinese Remainder Theorem


Under this section, we discuss a systematic way of solving systems of linear con-
gruences. It is believed that the Chinese mathematician Sun-Tsu suggested a
theorem to be used in the Chinese army to count soldiers. For instance, let us
assume that a group of approximately 1000 soldiers are to be counted. They are
lined up in say 3,4,5 and 7 columns, and it is noted how many soldiers are left
as “excess” in the last row. Thus, a system of 4 congruences with moduli 3,4,5,
and 7 is obtained. By the way, this system has a unique solution between 800
and 1200, by the following theorem.
34 Abubakar Mwasa

Theorem 5.28. Let n1 , n2 , ... , nr be positive integers such that (ni , nj ) = 1 for
i ̸= j. Then the system of linear congruences

x ≡ a1 (mod n1 )
x ≡ a2 (mod n2 )
...

x ≡ ar (mod nr )

has a solution, which is unique modulo to the integer n1 n2 ... nr .

Proof. Let n = n1 n2 ... nr for each k = 1, 2, ... , r. Let


n
Nk = = n1 n2 ... nk−1 nk+1 ... nr ,
nk

i.e. product of all the integers ni without nk . Then (Nk , nk ) = 1, and let x be a
unique integer such that Nk x ≡ 1(mod nk ).
Define x0 = a1 N1 x1 + a2 N2 x2 + ... + ar Nr xr . We observe that Ni ≡ 0(mod nk )
for i ̸= k because nk |Ni . Thus the result is

x0 = a1 N1 x1 + ... + ar Nr xr ≡ ak Nk xk (mod nk )

But the integer xk was chosen to satisfy the congruence Nk x ≡ 1(mod nk ), which
forces x0 ≡ ak · 1 ≡ (mod nk ). This shows that a solution to the given system of
congruence exists. For uniqueness, suppose x′ is any other integer that satisfies
these congruences, then x0 ≡ ak ≡ x′ (mod nk ), k = 1, 2, ... , r and so nk |x0 − x′
for each value of k.
Thus, n1 n2 ... nr |x0 − x′ , hence x0 ≡ x′ (mod n).

Example 5.29. Find a number x such that

x ≡ 3(mod 11), x ≡ 5(mod 19), x ≡ 10(mod 29).

Solution. Here ai = 1, n = 11(19)29 = 6061, n1 = 11, n2 = 19, n3 = 29.


N1 = 19 · 29, N2 = 11 · 29, N3 = 11 · 19.
Linear congruences 551x ≡ 1(mod 11), 11 · 29x ≡ 1(mod 19), 11 · 19x ≡
1(mod 29). Solving yields x1 = 1, x2 = 14, x3 = 5. Thus,

x0 = 3 · 19 · 29 + 5 · 11 · 29 · 14 + 10 · 5 · 11 · 19 = 34433 ≡ 4128(mod 6061).

Example 5.30. Solve the Sun-Tsu problem that corresponds to the system of
three congruences

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


Number Theory Lecture Notes 35

105 105 105


Solution. n = 3 · 5 · 7 and N1 = 3
= 35, N2 = 5
= 21, N3 = 7
= 15.
Now linear congruences

35x ≡ 1(mod 3), 21x ≡ 1(mod 5), 15x ≡ 1(mod 7)

are satisfied by x1 = 2, x2 = 1, x3 = 1, respectively.


Thus, x = 2 · 35 · 2 + 3 · 21 · 1 + 2 · 15 · 1 = 233. and x = 233 ≡ 23(mod 105).

Example 5.31. Solve the linear congruence 17x ≡ 9(mod 276).

Solution. 276 = 3 · 4 · 23. Then this is equivalent to finding a solution for


the system

17x ≡ 9(mod 3), 17x ≡ 9(mod 4), 17x ≡ 9(mod 23)

or
x ≡ 0(mod 3), x ≡ 1(mod mod 4), 17x ≡ 9(mod 23).
We have that x ≡ 0(mod 3), implying that x = 3k for some k ∈ Z. Then
3k ≡ 1(mod 4) from which we have k ≡ 9k ≡ 3(mod 4), so k = 3 + 4t, t ∈ Z.
Thus,
x = 3(3 + 4t) = 9 + 12t
And,

17(9 + 12t) ≡ 9(mod 23) ⇒ 153 + 204t ≡ 9(mod 23)


204t ≡ −144(mod 23) or 3t ≡ 6(mod 23) or t ≡ 2(mod 23)
so t = 2 + 23s, s ∈ Z.

Finally, x = 9 + 12(2 + 23s) = 33 + 276s, i.e. x ≡ 33(mod 276) is a solution to


the system.

Example 5.32. Find an integer which leaves remainder 5 when divided by 11


and 2 when divided by 19.

Solution. Let x be such a number, then

x ≡ 5(mod 11), x ≡ 2(mod 19)

We can solve this as follows

x ≡ 5(mod 11), so x = 5 + 11t for some integer t.

We choose t such that 5 + 11t ≡ 2(mod 19), 11t ≡ −3(mod 19). As (11, 19) = 1,
this has a unique solution. Since t = 17 satisfies 11t ≡ −3(mod 19), therefore
x = 5 + 11 · 11 ≡ 192(mod 11 · 19) = 192(mod 209).
36 Abubakar Mwasa

Remark 5.33. Suppose we are required to solve linear congruences in two vari-
ables ax+by ≡ c(mod n), then this congruence has a solution if and only if (a, b, n)
divides c. The condition for solvability holds if either (a, n) = 1 or (b, n) = 1.
For instance, if (a, n) = 1, then ax ≡ c − by(mod n) which guarantees a unique
solution x for each of the n incongruent values of y.
Example 5.34. Solve 7x + 4y ≡ 5(mod 12)
Solution. 7x ≡ 5 − 4y(mod 12), if y ≡ 5(mod 12). 7x ≡ −15(mod 12) but
this equivalent to −5x ≡ −15(mod 12) or x ≡ 3(mod 12), y ≡ 5(mod 12) is
one of the 12 incongruent solutions of 7x + 4y ≡ 5(mod 12). Another solution
x ≡ 3(mod 12), y ≡ 8(mod 12).
Theorem 5.35. The system of linear congruences

ax + by ≡ r(mod n) (5.4)
cx + dy ≡ s(mod n) (5.5)

has a solution modulo n, whenever (ad − bc, n) = 1.

Proof. d(5.4) − b(5.5),

(ad − bc)x ≡ dr − bs(mod n) (5.6)

The assumption that (ad − bc, n) = 1 ensures that the congruence (ad − bc)z ≡
1(mod n) has a unique solution.
Multiply (5.6) by t,
x ≡ t(dr − bs)(mod n)
And for y, c(5.4) − a(5.5), (ad − bc)y ≡ as − cr(mod n).
Implying y ≡ t(as − cr)(mod n).

Example 5.36. Solve the system

7x + 3y ≡ 10(mod 16) (5.7)


2x + 5y ≡ 9(mod 16) (5.8)

Solution. (ad − bc, n) = (7 · 5 − 2 · 3, 16) = (29, 16) = 1 a solution exists. So


5(5.7) − 3(5.8), 29x ≡ 5 · 10 − 3 · 9 ≡ 23(mod 16).
Multiplication by 5 produces x ≡ 35 ≡ 3(mod 16).
Similarly, 29y ≡ (7 · 9 − 2 · 10) ≡ 43(mod 16) or 13y ≡ 11(mod 16) which upon
multiplication by 5 produces y ≡ 55 ≡ 7(mod 16).
Example 5.37. Solve the system

5x + 3y ≡ 1(mod 7)
3x + 2y ≡ 4(mod 7)
Number Theory Lecture Notes 37

Solution. (ad − bc, n) = (5 · 2 − 3 · 3, 7) = (1, 7) = 1, then a solution exists.


So 10x − 9x ≡ 2 − 12(mod 7). x ≡ −10(mod 7) or x ≡ 4(mod 7).
Check that y ≡ 3(mod 7).
Exercise 5.38. (a) Use congruences to solve
(i) 3x − 7y = 11
(ii) 4x + 51y = 9
(b) A certain integer between 1 and 1200 leaves the remainders 1, 2, 6 when
divided by 9, 11, 13 respectively. What is the integer?
(c) Find all the solutions of the linear congruences 3x − 7y ≡ 11(mod 13).
(d) Find the solutions of each of the following systems of congruences
(i) 7x + 3y ≡ 6(mod 11), 4x + 2y ≡ 9(mod 11)
(ii) 11x + 5y ≡ 7(mod 20), 6x + 3y ≡ 8(mod 20)
(iii) x ≡ 1(mod 3), x ≡ 2(mod 5), x ≡ 3(mod 7)
(iv) 2x ≡ 1(mod 5), 3x ≡ 9(mod 6), 4x ≡ 1(mod 7), 5x ≡ 9(mod 11).

6. Theorems of Fermat, Euler and Wilson


Under this section, we discuss applications of the theory of congruences i.e. the-
orems of Fermat, Euler and Wilson.
“And perhaps posterity will thank me for having shown it that the
ancients did not know everything.” Pierre de Fermat.
First, we prove a theorem about the inverse of integers modulo prime numbers.
Theorem 6.1. Let p be a prime number. A positive integer m is its own inverse
modulo p if and only if p divides m + 1 or p divides m − 1.

Proof. Suppose that m is its own inverse, then m · m ≡ 1(mod p). Hence, p|m2 −
1 = (m−1)(m+1). In other words, p|(m−1) or p|(m+1), implying m ≡ 1(mod p)
or m ≡ −1(mod p).
Conversely, suppose that m ≡ 1(mod p) or m ≡ −1(mod p), then m2 ≡
1(mod p).

Theorem 6.2. [Wilson’s Theorem] If p is prime number, then p divides (p −


1)! + 1, i.e. (p − 1)! ≡ −1(mod p).

Proof. Note that if p = 2 and p = 3, the congruence holds. Now let us assume
that p > 3. Group the elements of the set {2, 3, ... , p − 2} in pairs (i, j) such that
i · j ≡ 1(mod p). Off course i ̸= j, otherwise the number (i − 1)(i + 1) would be
divisible by p, which is impossible due to that fact 0 < i − 1 < i + 1 < p. We
38 Abubakar Mwasa

already know from Theorem 6.1 that 1 and p − 1 are their own inverses. Hence
coupling the integers from 2 to p − 2 each with its inverse, it follows that their
product is 1. We get
2 · 3 · ... · (p − 2) ≡ 1(mod p)
and thus
(p − 1)! = 1 · 2 · 3 ... (p − 2)(p − 1) ≡ 1 · 1 · (p − 1) ≡ −1(mod p)
Conversely, let (p − 1)! ≡ −1(mod p). Assume that p is not prime. Then p has a
divisor d, 1 < d < p, and d divides (p − 1)!. But then d has to divide −1, which
is a contradiction.

Example 6.3. What is the remainder of


(a) 43! mod 47,
(b) 94! mod 97
Solution
(a) From Wilson’s Theorem, we have that
(47 − 1)! = 46 · 45 · 44 · 43! ≡ −1(mod 47)
(−1) · (−2) · (−3) · 43! ≡ −1(mod 47)
6 · 43! ≡ 1(mod 47)
Multiplying through by 6 gives
48 · 43! ≡ 8(mod 47)
43! ≡ 8(mod 47).
Thus when 43! is divided by 47 leaves a remainder of 8.
(b) Complete
Theorem 6.4. [Fermat’s Little Theorem (FLT)]. Let p be a prime number and
p ∤ a, then ap−1 ≡ 1(mod p).

Proof. Let p be prime and let p ∤ a, take the first p − 1 positive multiples of a,
i.e.
a, 2a, 3a, ... , (p − 1)a (6.1)
None of these numbers is congruent modulo p to any other, nor is any congruent
to zero.
Indeed, if it happened so, ra ≡ sa(mod p), 1 ≤ r < s < p. Then r ≡ s(mod p),
i.e. p|r − s which is impossible, since r, s < p. Thus, the set of multiples in (6.1)
must be congruent modulo p to 1, 2, ... , p − 1 and also
a · 2a · ... · (p − 1)a ≡ 1 · 2 · ... · (p − 1)(mod p).
Whence ap−1 (p − 1)! ≡ (p − 1)!(mod p) or ap−1 ≡ 1(mod p).
Number Theory Lecture Notes 39

Corollary 6.5. If p is a prime, then ap ≡ a(mod p) for any integer a.

Proof. If p|a, then a ≡ 0(mod p). So ap ≡ 0(mod p). And if p ∤ a, then by


Fermat theorem, ap−1 ≡ 1(mod p). Multiplying through by a, we have that
ap ≡ a(mod p).

NB. Fermat’s Theorem, in the least, can be a ‘labour saving device’ in certain
calculations.

Example 6.6. Show that 538 ≡ 4(mod 11), 7|3289 − 4.

Solution. By the Theorem 6.4, we have that 510 ≡ 1(mod 11).


Therefore 538 = (510 )3 (52 )4 ≡ 13 · 34 ≡ 81 ≡ 4(mod 11)

Remark 6.7. If an ≡ a(mod n) for some integers a and n, then n is prime is


false.

For example, if n = 117 and a = 2. We see that 2117 = (27 )16 · 25 . Check that
2117 ≡ 44(mod 117). Thus, 2117 ̸≡ 2(mod 117).
So n = 117 is not prime, actually it is a composite since 117 = 13 · 9.

Lemma 6.8. If p and q are distinct primes with ap ≡ a(mod q) and aq ≡


a(mod p), then apq ≡ a(mod pq).

Proof. By Theorem 6.4, (aq )p ≡ aq (mod p) and aq ≡ a(mod p) by hypothesis.


Implying that apq ≡ a(mod p) or p|apq − a.
Similarly, q|apq − a. Since p and q are distinct primes, we have that

pq|apq − a or apq ≡ a(mod pq).

Illustration.
Take 2340 ≡ 1(mod 341) or 2341 ≡ 2(mod 341). Here 341 = 11 · 31, product of
primes.
For 211 ≡ 2(mod 31). Since 211 = (25 )2 · 2 = 2(322 ) ≡ 2(mod 31). While for
2 ≡ 2(mod 11). 231 = (25 )6 · 2 ≡ (−1)6 · 2 ≡ 2(mod 11). Therefore, by the
31

lemma, we have that 2341 ≡ 2(mod 341).

Remark 6.9. It may be of some interest to know that 2n ≡ 2(mod n) for n < 340,
implying that n is prime. This led the Chinese to believe that n is prime if and
only if 2n ≡ 2(mod n) or n|2n − 2.

Definition 6.10. An integer n such that 2n ≡ 2(mod n) is called pseudoprime


though they can be prime as well as composite numbers.

There are infinitely many pseudoprimes, the smallest four being 341, 561, 645
and 1105.
40 Abubakar Mwasa

Theorem 6.11. If n is an odd pseudoprime, then Mn = 2n − 1 is a larger one.

Proof. Because n is a composite number, we can write n = rs, 1 < r ≤ s < n.


Thus, 2r − 1|2n − 1 or 2r − 1|Mn , making Mn composite.
By hypothesis, 2n ≡ 2(mod n), hence 2n − 2 = kn for some integer k. It
n
follows that 2Mn −1 = 22 −2 = 2kn .
This yields

2Mn −1 − 1 = 2kn − 1
= (2n − 1)(2n(k−1) + 22n(k−2) + ... + 2n + 1)
= Mn (2n(k−1) + 22n(k−2) + ... + 2n + 1)
≡ 0(mod Mn )

and 2Mn − 2 ≡ 0(mod Mn ), in light of which Mn is a pseudoprime.

Remark 6.12. There exist composite numbers n that are pseudoprimes to every
base a, i.e. an−1 ≡ 1(mod n) for all integers a with (a, n) = 1. The least being
561. They are called absolute pseudo primes or Carmicheal numbers (1910).
Carmicheal indicated such numbers, including 561 = 3 · 11 · 17, 1105 = 5 · 13 · 17,
2821 = 7 · 13 · 31, 15841 = 7 · 31 · 73.

For instance, 561 = 3 · 11 · 17. Notice that (a, 561) = 1 gives (a, 3) = (a, 11) =
(a, 17) = 1. Applying Theorem 6.4,

a2 ≡ 1(mod 3); a10 ≡ 1(mod 11), a16 ≡ 1(mod 17)

and in turn

a560 ≡ (a2 )280 ≡ 1(mod 3)


a560 ≡ (a10 )56 ≡ 1(mod 11)
a560 ≡ (a16 )35 ≡ 1(mod 17)

or a560 ≡ 1(mod 561) by Lemma 6.8.

Theorem 6.13. Let n be a composite square-free integer, one which is divisible


by no perfect square other than 1. Say n = p1 p2 ... pr where pi are distinct primes.
If pi − 1|n − 1 for i = 1, 2, ... , r. Then n is an absolute pseudoprime.

Proof. Let a ∈ Z satisfying (a, n) = 1 so that (a, pi ) = 1 for each i. Then


Theorem 6.4 yields pi |api −1 − 1 or api −1 ≡ 1(mod pi ). By assumption, pi − 1|n − 1,
we have that pi |an−1 −1 and therefore pi |an −a for all values of a and i = 1, 2, ... , r.
Thus, n|an − a.
Number Theory Lecture Notes 41

Examples of integers satisfying the above theorem include 1729 = 7 · 13 · 19,


6601 = 7 · 23 · 41, 10585 = 5 · 29 · 73.
Exercise 6.14. (a) Use Fermat’s Theorem to verify that 17 divides 11104 + 1
(b) For n = 195 = 3 · 5 · 13, verify that an−2 ≡ a(mod n) for any integer a
(c) If (a, 35) = 1, show that a12 ≡ 1(mod 35)
(d) If (a, 133) = (b, 133) = 1, show that 133|a18 − b18
(e) Show that 561|2561 − 2 and 561|3561 − 3.
Euler’s theorem generalises Fermat’s Theorem to the case where the modulus
is composite.
Definition 6.15. The Euler φ-function is the function of positive integers defined
as φ(n) =(the number of integers in {1, 2, ... , n − 1} which are relatively prime
to n).
For instance, if n = 24. Then the numbers which are less than and relatively
prime to 24 are
{1, 5, 7, 11, 13, 17, 19, 23}
Thus, φ(24) = 8. And φ(11) = 10.
Exercise 6.16. Find φ(8), φ(101)
Proposition 6.17. (a) If n is prime, the φ(n) = n − 1
(b) If p is prime, and n ≥ 1, then φ(pn ) = pn − pn−1 = pn (1 − p1 )
(c) φ(n) counts the elements in {1, 2, ... , n − 1} which are invertible modulo n

Proof. (a) If n = p is prime, then all integers {1, 2, ... , p − 1} are relatively
prime to p. Hence, φ(p) = p − 1.
(b) There are pn elements in {1, 2, ... , pn }. An element of this set is not rela-
tively prime to p if and only if it is divisible by p. And the only elements
in the set which are divisible by p are

1 · p, 2 · p, ... , pn−1 · p

Observe that the last element in the set is pn−1 · p = pn . Thus, there are
pn−1 elements where are divisible by p. Hence, there are pn − pn−1 elements
of the set which are relatively prime to p.
(c) Recall that (a, n) = 1 if and only if ax ≡ 1(mod n) for some x. Implying
that (a, n) = 1 if and only if a is invertible modulo n. Now φ(n) is the
number of elements in {1, 2, ... , n − 1} which are relatively prime to n.
Thus, φ(n) is also invertible modulo n.

Theorem 6.18. The function φ is a multiplicative function, i.e. φ(mn) = φ(m)φ(n)


for (m, n) = 1 where m, n ≥ 1 are positive integers.
42 Abubakar Mwasa

Theorem 6.19. If the integer n > 1 has prime factorization n = pk11 pk22 ... pkr r ,
then

φ(n) = (pk11 − pk11 −1 )(pk22 − pk22 −1 ) ... (pkr r − pkr r −1 )


r
1 1 1 Y 1
= n(1 − )(1 − ) ... (1 − ) = n (1 − ).
p1 p2 pr i=1
pi

Proof. If r = 1, then φ(n) = n(1 − p11 ), where n = pk11 .


For r = i, φ(n) = φ(pk11 )φ(pk22 ) ... φ(pki i ), for i = 1, 2, ... , r. Thus
r
Y 1
φ(n) = (pk11 − pk11 −1 )(pk22 − pk22 −1 ) ... (pkr r − pkr r −1 ) = n (1 − ).
i=1
pi

Example 6.20. Find φ(360), φ(100), φ(36000), φ(5040)

Solution. Note that 360 = 23 · 32 · 5.


1 1 1 1 2 4
φ(360) = 360(1 − )(1 − )(1 − ) = 360 · · · = 96.
2 3 5 2 3 5
Theorem 6.21. For n > 2, φ(n) is an even integer.

Definition 6.22. A complete residue system modulo m is a set of integers a1 , ... , am


such that ai ̸≡ aj (mod m) if i ̸= j and any integer n is congruent to some ai mod-
ulo m.

Alternatively, let m ∈ N, a complete residue system modulo m is a subset


S = {a1 , ... , ak } ⊂ Z such that

(i) |S| = m,

(ii) for any two ai , aj ∈ S with ai ̸= aj , we have ai ̸≡ aj (mod m).

Definition 6.23. A reduced residue system modulo m is a set of integers a1 , ... , ak


such that ai ̸≡ aj (mod m) if i ̸= j and (ai , m) = 1 for all i, and any integer n
coprime to m must be congruent to some ai modulo m.

For example, if m = 12, then {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11} is a complete residue


system modulo 12. and {1, 5, 7, 11} is a reduced residue system. Notice that each
element in the set is relatively prime to 12.

Definition 6.24. The number of elements in a reduced residue system mod m


is called Euler’s totient function, φ(m), i.e. the number of positive integers ≤ m
and coprime to m.
Number Theory Lecture Notes 43

Lemma 6.25. Let {r1 , r2 , ... , rk } be a reduced residue system modulo m, where
k = φ(m). Let (a, m) = 1. Then {ar1 , ar2 , ... , ark } is also a reduced residue
system modulo m.

Proof. Required to show (ari , m) = 1 and distinct modulo m. First, we know


that if (r, m) = 1 and (a, m) = 1, then (ar, m) = 1. Also, if (a, m) = 1, then
m|ri − rj implying ri ≡ rj (mod m), which is not possible unless i = j.

Theorem 6.26. [Euler’s Theorem] If (a, m) = 1, then aφ(m) ≡ 1(mod m).

Proof. Let r1 , r2 , ... , rφ(m) be a reduced residue system modulo m. By Lemma 6.25,
ar1 , ar2 , ... , arφ(m) is also a reduced residue system modulo m. Thus,

ar1 ar2 ... arφ(m) = aφ(m) r1 r2 ... rφ(m) (mod m).

Now, since (ri , m) = 1 for all 1 ≤ i ≤ φ(m), we have that

(r1 r2 ... rφ(m) , m) = 1.

Example 6.27. Note that 34 = 81 ≡ 1(mod 5).


Also, 2φ(9) = 26 = 64 ≡ 1(mod mod 9).

7. Number Theoretic Functions (Arithmetic func-


tions)
Till now, we have learnt about the basic properties of integers.
In this section, we study the arithmetic functions of positive integers N which
reflect some further properties of integers.
“Mathematicians are like Frenchmen: Whatever you say to them, they trans-
late into their own language and forthwith it is something entirely different”,
Goethe.

Definition 7.1. An arithmetic function is a function whose domain is the set of


positive integers.

For example, define f : N → R by f (n) = sin n. Then f is an arithmetic


number.
For each positive integer n, denote the number of positive divisors of n by
τ (n) and the sum of positive divisors by σ(n), i.e. τ : N → N and σ : N → N
are functions defined respectively as
X X
τ (n) = 1 and σ(n) = d
d|n d|n
d≥1 d≥1
44 Abubakar Mwasa

Example 7.2. (a) Let n = 12, positive divisors of 12 are 1, 2, 3, 4, 6, 12. Then
τ (12) = 6 and σ(12) = 1 + 2 + 3 + 4 + 6 + 12 = 28.
(b) Let n = 5, then τ (5) = 2 and σ(5) = 1 + 5 = 6.

In fact if n is prime, then τ (n) = 2 and σ(n) = n + 1.X


It is customary to interpret the symbol [D(f )](n) = f (d) to mean “sum
d|n
of the values f (d) as d runs over all the positive divisors of the positive integer
n”. For instance, if n = 20
X
f (d) = f (1) + f (2) + f (4) + f (5) + f (10) + f (20)
d|20

If n = 10; X
τ (10) = 1=1+1+1+1=4
d|10

we assign 1 to each positive divisor of 10, while


X
σ(10) = = 1 + 2 + 5 + 10 = 18.
d|10

Example 7.3. Let f : N → N is defined by f (n) = n2 . Compute [D(f )](12).

Solution. Let [D(f )](n) is the sum of the squares of the divisors of n.
X
[D(f )](12) = d2 = 12 + 22 + 32 + 42 + 62 + 122 = 210.
d|12

Theorem 7.4. If n = pk11 pk22 ... pkr r is the prime factorization of n > 1, then the
positive divisors of n are precisely those integers d of the form d = pa11 pa22 ... par r
where 0 ≤ ai ≤ ki , i = 1, 2, ... , r.

Proof. Divisor d = 1, when a1 = a2 = ... = ar = 0 and n itself occurs when


a1 = k1 , a2 = k2 , ..., ar = kr . Suppose that d divides n non trivially, say n = dd′ ,
where d > 1, d′ > 1. Express both d and d′ as product of (not necessarily distinct)
primes i.e. d = q1 q2 ... qs and d′ = t1 t2 ... tu with each qi , tj prime. Then

pk11 pk22 ... pkr r = q1 q2 ... qs t1 t2 ... tu

are two prime factorizations of the positive integer n. By uniqueness, each prime
qi must be one of the pj and rearranging

d = q1 q2 ... qs = pa11 pa22 ... par r

where possibility of ai = 0 is allowed.


Number Theory Lecture Notes 45

Conversely, every number d = pa11 pa22 ... par r , 0 ≤ ai ≤ ki turns out to be the
divisor of n i.e.

n = pk11 pk22 ... pkr r = (pa11 pa22 ... par r )(pk11 −a1 pk22 −a2 ... pkr r −ar )

with d′ = pk11 −a1 p2k2 −a2 ... prkr −ar and ki − ai ≥ 0 for each i. Then d′ > 0 and
d|n.

Theorem 7.5. If n = pk11 pk22 ... pkr r is the prime factorization of n > 1, then
(a) τ (n) = (k1 + 1)(k2 + 1) ... (kr + 1)
pk11 +1 − 1 pk22 +1 − 1 pkr +1 − 1
(b) σ(n) = · · ... · r .
p1 − 1 p2 − 1 pr − 1

Proof. skipped

Note that if n = pk11 pk22 ... pkr r , then


r r
Y Y piki +1 − 1
τ (n) = (ki + 1) and σ(n) =
i=1 i=1
pi − 1

Example 7.6. The prime factorization of the number n = 180 is 22 · 32 · 5.


Then τ (180) = (2 + 1)(2 + 1)(1 + 1) = 18 divisors. These integers are of the
form 2a1 · 3a2 · 5a3 , where a1 = 0, 1, 2, a2 = 0, 1, 2 and a3 = 0, 1. Specifically
{1, 2, 3, 4, 5, 6, 9, 10, 12, 15, 18, 20, 30, 36, 45, 60, 90, 180}.
While the sum of the integers is

23 − 1 33 − 1 52 − 1
σ(180) = · · = 7 · 13 · 6 = 546.
2−1 3−1 5−1

Example 7.7. The number n = 7056 = 24 ·32 ·72 has τ (n) = (4+1)(2+1)(2+1) =
45 and
25 − 1 33 − 1 73 − 1
σ(n) = · · = (31 · 26 · 342)/12 = 204321
2−1 3−1 7−1
We remark here that divisor function τ isYthe product of the positive divisors
of an integer n > 1 equal to nτ (n)/2 , that is d = nτ (n)/2 . For instance,
d|n

Y
d = 16τ (16)/2 = 165/2 = 45 = 1024.
d|16

Definition 7.8. A number theoretic function f is said to be multiplicative if


f (mn) = f (m)f (n) whenever (m, n) = 1.
46 Abubakar Mwasa

In general, if f is multiplicative and n1 , n2 , ... , nr are positive integers that


are pairwise relatively prime, then
f (n1 n2 ... nr ) = f (n1 )f (n2 ) ... f (nr ).
Theorem 7.9. The functions τ and σ are both multiplicative functions
Proof. Let (m, n) = 1. If m or n = 1, then the result is trivially true. If m > 1,
n > 1. Then m = pk11 pk22 ... pkr r and n = q1j1 q2j2 ... qsjs are prime factorizations of m
and n. Since (m, n) = 1, no pi occurs among qj . It follows that
mn = pk11 pk22 ... pkr r q1j1 q2j2 ... qsjs
Thus, τ (mn) = [(k1 + 1)(k2 + 1) ... (kr + 1)][(j1 + 1)(j2 + 1) ... (jj + 1)] = τ (m)σ(n).
Similarly,
pk11 +1 − 1 pkr r +1 − 1 q1j1 +1 − 1 qsjs +1 − 1
σ(mn) = ... · ... = σ(m)σ(n).
p1 − 1 pr − 1 q1 − 1 qs − 1

Remark 7.10. If f is a multiplicative function and F is defined by


X
F (n) = f (d), then F is also multiplicative.
d|n

For instance,
X
F (24) = F (8 · 3) = f (d)
d|24

= f (1) + f (2) + f (3) + f (4) + f (6) + f (8) + f (12) + f (24)


= f (1 · 1) + f (2 · 1) + f (1 · 3) + f (4 · 1) + f (2 · 3) + f (8 · 1)
+ f (4 · 3) + f (8 · 3)
= f (1)f (1) + f (2)f (1) + ... + f (8)f (3)
= [f (1) + f (2) + f (4) + f (8)][f (1) + f (3)]
X X
= f (d) · f (d) = F (8)F (3).
d|8 d|3

Exercise 7.11. (a) Evaluate τ (n) and σ(n) for n = 987, n = 36000.

8. Primitive Roots
Recall from Euler’s theorem that if (a, m) = 1, then aφ(m) ≡ 1(mod m). Then,
there exist positive integer h such that ah ≡ (mod m). The least such integer h is
called exponent or order of a(mod m), i.e. ah ≡ 1(mod m), then h is an exponent
of a modulo m.
Number Theory Lecture Notes 47

Example 8.1. (a) Find the order of 3 modulo 5.


(b) Show that the exponent of 2 modulo 8 is not defined.
Solution.

31 ≡ 3(mod 5),
32 ≡ 4(mod 5),
33 ≡ 2(mod 5),
34 ≡ 1(mod 5).

Thus the order of 3 modulo 5 is 4.

Note that if an integer has order h modulo m, we say that a has order
h(mod m).

Theorem 8.2. Let a be an integer having order h modulo m, the the following
hold.

(i) (a, m) = 1,

(ii) If ak ≡ 1(mod m), for some integer k, then h|k.

(iii) If a ≡ b(mod m), then b has order h modulo m.

(iv) ai ≡ aj (mod m), if and only if i ≡ j(mod h).

Proof

(i) Let d > 0 be a common divisor of a and m. Then d|a and d|m since
ah ≡ 1(mod m), then

ah ≡ 1 + km for some k ∈ Z

Now d|a, implying d|ah and so d|m. Thus d|ah − km = 1, thus d = 1.

(ii) If ak ≡ 1(mod m), then by the definition of the exponent k ≥ h and by


Division Algorithm

k = hq + r, 0 ≤ r < h,
ak = ahq+r = ahq · ar

So 1 ≡ 1q · ar (mod m) and 1 ≡ ar (mod m). But r < h and h is the order of


a(mod m). So 1 ≡ ar (mod m) holds only when r = 0.
Therefore, k = hq or h|k.

(iii) Let a ≡ b(mod m), then ah ≡ bh (mod m). But ah ≡ 1(mod m), implying
that bh ≡ 1(mod m).
48 Abubakar Mwasa

(iv) First, suppose that ai ≡ aj (mod m). Because a is relatively prime to m, so

a|i−j| ≡ 1(mod m)

and by Theorem 8.2 (ii) above, h||i − j| i.e. i ≡ j(mod h).


Conversely, let i ≡ j(mod h). then we have that i = j + qh for some integer
q. By the definition of h, ah ≡ 1(mod m), so that

ai ≡ aj+qh = aj (ah )q ≡ aj (mod m).

Corollary 8.3. If a has order h modulo m, then the integers a, a2 , ... , ah are
incongruent modulo m.

Proof. If ai ≡ aj (mod m) for 1 ≤ i ≤ j ≤ h, then by Theorem 8.2 (iv) ensures


that i ≡ j(mod m). But this is impossible unless i = j.

Theorem 8.4. If the integer a has order h modulo m and k > 0, then ak has
order kd modulo m, where d = (h, k).

Proof. Let d = (h, k). Then h = h1 d and k = k1 d with (h1 , k1 ) = 1. Clearly,

(ak )h1 = (ak1 d )h/d = (ah )k1 ≡ 1(mod m)

If ak is assumed to have order r modulo m, then Theorem 8.2 (ii) above asserts
that r|h1 .
On other hand, because a has order h modulo m, the congruence

akr = (ak )r ≡ 1(mod m)

indicates that h|kr or h1 d|k1 dr or h1 |k1 r. But (h1 , k1 ) = 1 and h|r, so r = k1 = kd ,


where d = (h, k).

Corollary 8.5. Let a have order h modulo m. Then ak also has order h if and
only if (h, k) = 1.

Example 8.6. The following table exhibits the orders modulo 13 of the positive
integers less than 13.

integer 1 2 3 4 5 6 7 8 9 10 11 12
order 1 12 3 6 4 12 12 4 3 6 12 2

Observe that order of 2 Modulo 13 is 12, whereas the orders of 22 and 23 are
12 12
6 and 4, respectively. It is easy to verify that 6 = and 4 = in
(2, 12) (3, 12)
accordance with Theorem 8.4.
Number Theory Lecture Notes 49

The integers that also have order 12 modulo 13 are powers 2k for which
(k, 12) = 1. Namely,
21 ≡ 2, 25 ≡ 6, 27 ≡ 11, 211 ≡ 7(mod 13)
If an integer a has the largest order possible, then this is called a primitive root
of m.
Definition 8.7. If (a, m) = 1 and a is of order φ(m) modulo m, then a is a
primitive root of the integer m.
Note that 1m ≡ 1 for all integers m, hence 1 can never be a primitive root of
any integer greater than 2.
Example 8.8. List the primitive roots modulo 6.
Solution. Note that φ(6) = 2. Any integer(mod 6) is congruent to one of
0, 1, 2, 3, 4, 5. Thus, primitive roots modulo 6 will be among 2, 3, 4, 5. But then
22 ≡ 4(mod 6)
32 ≡ 3(mod 6)
42 ≡ 4(mod 6)
52 ≡ 1(mod 6)
Thus, 5 is the only primitive root modulo 6.
Example 8.9. List the primitive roots modulo 7.
Solution. Note that φ(7) = 6. Thus, the primitive roots (mod 7) are among
2, 3, 4, 5, 6.
Observe that 22 ≡ 4(mod 7), 23 ≡ 1(mod 7) from which we have that 26 ≡
4(mod 7). So, 2 is not a primitive root (mod 7).
Also 32 ≡ 2(mod 7), 34 ≡ 4(mod 7), then 36 ≡ 1(mod 7). So 3 is a primitive
root (mod 7).
As 42 ≡ 2(mod 7) and 43 ≡ 1(mod 7). The number 4 cannot be a primitive
root(mod 7). Also,
52 ≡ 4(mod 7)
54 ≡ 2(mod 7)
56 ≡ 1(mod 7)
53 ≡ 6(mod 7)
55 ≡ 3(mod 7)
so, 5 is also a primitive root (mod 7). Finally, 62 ≡ 1(mod 7), so 6 cannot be a
primitive root mod 7. Hence, 3 and 5 are the only primitive roots (mod 7).
Exercise 8.10. (a) List all primitive roots modulo 10.
(b) Show that there are no primitive roots modulo 8
(c) Find the order of the integer (i) 2 modulo 17, (ii) 5 modulo 23.
50 Abubakar Mwasa

9. Perfect numbers and Mersenne primes


Just like prime numbers, search for perfect numbers began many years ago and
continues until today. In fact, Mersenne primes Mp are closely linked to perfect
numbers. In the 4th century BC, Euclid proved that if 2p − 1 is prime, then
2p−1 (2p − 1) is a perfect number.

Definition 9.1. A positive integer, n > 0, is a perfect number if σ(n) = 2n.


Alternatively, n is a perfect number if it is equal to the sum of its divisors other
than itself.

Example 9.2. Show that 6 and 28 are perfect numbers.

Solution. Divisors of 6 other than itself are {1, 2, 3}. Now 6 = 1 + 2 + 3, so


6 is a perfect number or σ(6) = 1 + 2 + 3 + 6 = 12. Since σ(6) = 2 · 6 = 12, then
6 is a perfect number.
Check that 28 is perfect.
Recall; A Mersenne prime is a prime of the form Mp = 2p − 1, p is prime.
A few perfect numbers that were already known by the Greeks are 6, 28, 496
and 8128. As earlier mentioned, all even perfect numbers can be represented by
2p−1 (2p − 1), p is prime.

Example 9.3. The table below shows the relationship between Mersenne prime
and perfect numbers.

Prime, p Mersenne Prime Perfect number


2p − 1 2p−1 (2p − 1)
2 3 6
3 7 28
5 31 496
7 127 8128
13 8191 33550336

Definition 9.4. A positive integer n > 0 is abundant is σ(n) > 2n and is deficient
if σ(n) < 2n.

Example 9.5. n = 10 is deficient since σ(10) = 1 + 2 + 5 + 10 = 17 < 2(10) and


n = 12 is abundant since σ(12) = 1 + 2 + 3 + 4 + 6 + 12 = 28 > 2(12).

It is not known whether there are infinitely many perfect numbers or there
are any odd perfect numbers? So far, all the perfect numbers known are even.

Theorem 9.6. [Euler]. Let n > 0 be a positive integer. Then n is an even perfect
number if and only if n = 2p−1 (2p − 1) for a prime p and 2p − 1 prime.

The proof for this result is delayed. Example, see the table above.
Number Theory Lecture Notes 51

Example 9.7. What perfect number corresponds to the Mersenne prime 27 −1 =


127?

Solution. 26 (27 − 1) = 8128 is a perfect number.

Lemma 9.8. Let a, b be positive integers. Then

(2a − 1, 2b − 1) = 2(a,b) − 1

Example 9.9. Compute (242 − 1, 254 − 1).

Solution. (42, 54) = 6. Thus, (242 − 1, 254 − 1) = 26 − 1 = 63.

10. Quadratic residues


Definition 10.1. Let (a, n) = 1, n > 0, a is a quadratic residue modulo n if
x2 ≡ a(mod n) has a solution. Otherwise, a is a quadratic nonresidue modulo n.

Example 10.2. (a) is 8 a quadratic residue modulo 17?


(b) Find all the quadratic residues modulo 18.

Solution.
(a) Note that 52 ≡ 8(mod 17). Thus, 8 is a quadratic residue modulo 17.
(b) Reduced residue system modulo 18 = {1, 5, 7, 11, 13, 17}. Computing their
squares modulo 18
x 1 5 7 11 13 17
2
x (mod 18) 1 7 13 13 7 1
The quadratic residues are squares i.e. 1, 7, 13. Since x2 = (−x)2 , this
explains why row 2 in the table is symmetric left-to-right.

Example 10.3. Determine all positive integers n for which

Nn = 1! + 2! + ... + n! is a square.

Solution. Note that N1 − 1 and N3 − 9 are squares while N2 − 3 is not a square.


For n ≥ 4, we have

Nn ≡ 1! + 2! + 3! + 4! ≡ 33 ≡ 3(mod 5)

So, Nn cannot be a square because it is not a quadratic residue modulo 5.

Example 10.4. Determine all positive integers n for which

Sn = (1!)2 + (2!)2 + ... + (n!)2 is a square.


52 Abubakar Mwasa

Solution. Observe that among S1 , S2 , S3 , only S1 is a square. For n ≥ 4, we


have

Sn ≡ (1!)2 + (2!)2 + (3!)2 + (4!)2 ≡ 617 ≡ 2(mod 5), so Sn is not a square.

Lemma 10.5. Let p be an odd prime and consider the congruence x2 ≡ a(mod p),
(a) the only solution is x = 0 or if a = 0.
(b) there are exactly 0 or 2 solutions if p ∤ a.

Proof. (a) Indeed x = 0 solves x2 ≡ 0(mod p). Conversely, if x2 ≡ 0(mod p),


then p|x2 , so p|x and hence x ≡ 0(mod p).
(b) Suppose p ∤ a. Suppose there is at least one solution b. then b2 ≡ a(mod p),
so (−b)2 ≡ a(mod p). Assume that b and −b are distinct. If not, then
b ≡ −b(mod p), so p|2b. But p is odd, so p ∤ 2.
Therefore, p|b, b ≡ 0(mod p), b2 ≡ 0(mod p) and finally a ≡ 0(mod p).
Contradicting p ∤ a, hence b ̸≡ −b(mod p). If b and −b are distinct, then
indeed quadratic equation modulo p has at most two solutions.

Example 10.6. The congruence x2 ≡ 8(mod 17) has 5 and 12 as solutions and
5 ≡ −12(mod). On other hand, quadratic residues modulo 17 are {1, 2, 4, 8, 9, 13, 15, 16}.
Thus, x2 ≡ 5(mod 17) has no solutions.

NB. The result is false if p = 2, since x2 ≡ 1(mod 2) has exactly one solution
x ≡ 1(mod 2).

Theorem 10.7. Let p be an odd prime number. A reduced residue system modulo
p consists of p−1
2
quadratic residues and p−1
2
quadratic nonresidues.

Proof. Each quadratic residue modulo p is congruent to the square of some of


the numbers
p−1 p−1
− , ... , −1, 1, ... ,
2 2
that is to say, it is congruent to some of the numbers 12 , 22 , ... , ((p − 1)/2)2 . It
remains to show that these p−1 2
are incongruent modulo p. Assume that k 2 ≡
l2 (mod p), where 1 ≤ k < l ≤ p−1 2
. Then (l − k)(l + k) ≡ 0(mod p) so l −
k ≡ 0(mod p) or l + k ≡ 0(mod p), contradiction, because 0 < l − k < p and
0 < l + k < p.

Definition 10.8. Let p be an odd prime and let (a, p) = 1. The Legendre symbol,
a

p
is defined by
  (
a 1, if a is a quadratic residue mod p
=
p −1, if a is a quadratic nonresidue mod p.
Number Theory Lecture Notes 53

Note that a = 0 is disallowed (since (0, p) = p ̸= 1) even though x2 ≡ 0(mod p)


has a solution.  
4
= 1, since 4 ≡ 22 (mod 11).
11
On the other hand,
 
5
= −1, since x2 ≡ 5(mod 17) has no solutions.
17

Theorem 10.9. [Euler’s criterion]. For any integer a and any odd prime number
p, we have  
a p−1
≡ a 2 (mod p).
p

“These notes are still under development, any suggestions are highly welcome.”

11. Some special features in number theory


(a) 144 is a special number?
ˆ Why 144 is a perfect square i.e. 122 = 144.
ˆ Sum of its digits is also a perfect square i.e. 1 + 4 + 4 = 9 = 32
ˆ Product of its digits is a perfect square i.e. 1 × 4 × 4 = 16 = 42
ˆ Its reverse is also a perfect square i.e. 441 = 212
ˆ 144 = 122 while 441 = 212
ˆ 144 can be written as a sum of 2 twin primes, i.e. 71 + 73 = 144
ˆ It is a Harsad number, i.e. divisible by the sum of its digits

References
1. Sloane, N. J. A. (ed.), “Sequence A007508 (Number of twin prime pairs
below 10n )”, The On-Line Encyclopedia of Integer Sequences. OEIS Foun-
dation. Retrieved 2019-11-01. 15
2. David M. Burton, Elementary Number Theory, 7th ed., Tata McMraw-Hill
Pub. Company LtD, New Delhi, India, 2011.
3. Malik S.B, Basic Number Theory, 2nd ed., Vikas Publishing House, New
Delhi, India, 2009.
4. Hardy, G.H. and Wright, E.M, An Introduction to the Theory of Num-
bers, 5th Edition, Oxford University Press, 1979.
5. James J. Tattersall, Elementary Number Theory in Nine Chapters,
Cambridge University Press, 1999.
54 Abubakar Mwasa

6. William Stein, Elementary Number Theory: Primes, Congruences and Se-


crets, .

You might also like