Professional Documents
Culture Documents
Lesson 6 - Number Theory & Cryptography: Definition 1
Lesson 6 - Number Theory & Cryptography: Definition 1
Number theory, also referred to as ‘higher arithmetic’, is the branch of mathematics that
involves the study of integers and their properties. In this lesson, we will explore some basic
concepts of number theory including divisibility, modular arithmetic, and primes. We will
also briefly discuss cryptography which is a quite interesting and extremely useful application
of number theory.
Definition 1:
Let a and b be two integers with a ≠ 0. Suppose that there exists an integer c such that b = ac.
Then we say that a divides b. In this case, we say that a is a factor of b and that b is a multiple
of a.
To denote that a divides b, we use the notation a | b. Further, when a does not divide b, we
write a ∤ b.
1
Example 6.1.1
It can easily be seen that 20/4 = 5, and hence 4 | 20. Since 17/6 is not an integer, it follows
that 6 ∤ 17.
Theorem 1:
Let a, b, and c be integers. Then the following hold.
i. if a | b and a | c, then a | (b + c);
ii. if a | b, then a | bc for all integers c;
iii. if a | b and b | c, then a | c.
Proof:
We will first give a direct proof of (i). Suppose that a | b and a | c. Then, from the definition
of divisibility, it follows that there are integers s and t with b = as and c = at.
Hence, b + c = as + at = a(s + t). Therefore, a divides b + c. This establishes part (i) of the
theorem.
For the proof of part (ii), suppose that a | b. Then, from the definition of divisibility, we have
that there is an integer s with b = as. Now observe that a divides bc = asc. Hence part (ii) of
the theorem.
For part (iii), suppose that a | b and b | c. Then, by the definition of divisibility, we know that
there are integers s and t with b = as and c = bt. Hence, c = ast. Therefore, a divides c. Thus,
the proof of part (iii) of the theorem is complete.
If a, b, and c are integers such that a | b and a | c, then a | mb + nc whenever m and n are
integers.
Proof: We will give a direct proof of the above corollary. By part (ii) of the Theorem 1, it
follows that a | mb and a | nc whenever m and n are integers. By part (i) of the Theorem 1, we
have that that a | mb + nc. Hence the corollary. ∎
2
When we divide an integer by another integer, the operation produces a quotient and a
remainder as illustrated in the division algorithm.
In the division algorithm, a is called the dividend, d is called the divisor, q is called the
quotient, and r is called the remainder. The following notations are used to express the
quotient and remainder respectively.
q = a div d, r = a mod d
Example 6.2.1
Notice that the quotient and remainder when 27 is divided by 4 are 6 and 3 respectively. So,
we write 27 = 4 ∙ 6 + 3. Also, we have 6 = 27 div 4 and 3 = 27 mod 4.
Example 6.2.2
Let us consider the quotient and remainder when -23 is divided by 5. Observe that -23 = 5 ∙ (-
5) + 2. So, we have -5 = -23 div 5 and 2 = -23 mod 5. Notice that the remainder is always
non-negative.
If the remainder of an integer x upon division by another integer y is zero, we say that x is
divisible by y, or alternatively, y divides x.
Division of an integer by another integer produces a remainder the study of which leads us to
modular arithmetic. If two integers a and b have the same remainder upon division by a
positive integer m, then we say that a is congruent to b modulo m. This is indicated by the
notation a ≡ b mod m. We use the notation a ≢ b mod m to denote that a and b are not
congruent modulo m.
3
Definition 2:
Let a and b be integers and m be a positive integer. We say that a is congruent to b modulo m,
if m divides a - b.
Theorem 3:
Let a and b be integers, and let m be a positive integer. Then a ≡ b mod m if and only
if a mod m = b mod m.
Example 6.3.1
First, let us determine whether 17 is congruent to 3 modulo 7. It is easy to observe that 7
divides 17 – 3 – 14. So, we conclude that 17 ≡ 3 mod 7. Now we check whether 21 is
congruent to 6 modulo 8. Note that 21 – 6 = 15 is not divisible by 8, and hence 21 ≢ 6 mod 8.
Theorem 4:
Let m be a positive integer. If a ≡ b mod m and c ≡ d mod m, then a + c ≡ (b + d) mod m and
ac ≡ bd mod m.
Example 6.3.2
Because 12 ≡ 2 mod 5 and 16 ≡ 1 mod 5, it follows from Theorem 3 that 28 = 12 + 16 = 2 +
1 ≡ 3 mod 5 and that 192 = 12 ∙ 16 ≡ 2 mod 5.
Definition 3:
The set of all integers that have the same remainder as a when divided by n is known as the
congruence class of a modulo n.
Example 6.3.3
Since … = -40 = -33 = -26 = -19 = -12 = -5 = 2 = 9 = 16 = 23 = 30 = 37 = … ≡ 2 mod 7, the
set of numbers {…-40, -33, -26, -19, -12, -5, 2, 9, 16, 23, 30, 37…} forms the congruence
class of 2 modulo 7.
4
Every positive integer greater than 1 is divisible by at least two integers, because a positive
integer is divisible by 1 and by itself.
Definition 4:
A positive integer p greater than 1 is called prime if the only positive factors of p are 1 and p.
A positive integer that is greater than 1 and is not prime is called composite.
A prime number is a natural number greater than 1 that cannot be written as the product of
two smaller natural numbers.
Remark: The integer n is composite if and only if there exists an integer a such that a | n and
1 < a < n.
Example 6.4.1
Notice that 7 is prime because its only divisors are 1 and itself. That is, the only ways of
writing 7 as a product of two natural numbers are 1 × 7 or 7 × 1, and they involve 7 itself.
Example 6.4.2
Observe that 6 is not prime because it has two divisors other than 1 and itself, namely 2 and
3. That is, 6 is the product of two numbers 2 × 3 which are both smaller than 6. So, 6 is a
composite number.
Example 6.4.3
All even integers greater than 2 are not prime. Note that every even integer x greater than 2
can be written as the product of 2 and x/2 (which is an integer since x is even). Therefore,
every even integer greater than 2 is composite.
The famous Greek mathematician Euclid contributed to the following important result on
prime numbers.
5
Theorem 5:
There are infinitely many primes.
Remark 2: It has been known since ages that there are infinitely many primes.
This means that if p1, p2, …, pn are the n smallest primes, then there is a larger
prime which doesn’t appear in this list.
Primes play an integral role in number theory due to the fundamental theorem of arithmetic.
Example 6.4.4
Check whether each number in the set A = {4, 5, 12, 49, 748} is prime or composite. For
numbers which are composite, write their unique prime factorization.
Solution:
4 is composite, and we have the unique prime factorization 4 = 22.
5 is prime.
12 is composite, and we have the unique prime factorization 12 = 22 × 3.
49 is composite, and we have the unique prime factorization 49 = 72.
748 is composite, and we have the unique prime factorization 748 = 22 × 11 x 17.
Self-Assessment Exercises:
1. Suppose that a | b and a | c where a, b and c are integers. Prove that a | (b - c).
7
9. Find the congruence classes of the following,
a) 3 modulo 5.
b) 7 modulo 9.
10. Determine whether the following numbers are prime or composite. For numbers which
are composite, write their unique prime factorization.
a) 8
b) 45
c) 77
d) 37
e) 29
8
Quite importantly, congruences have many applications in discrete mathematics and
computer science. One such interesting application of congruences is cryptography which
involves the study of secret messages. There are two main aspects in cryptography namely,
encryption which is the process of making messages secret, and decryption which refers to
the process of determining the original message from the encrypted version. One of the
earliest known uses of cryptography is Caesar’s cypher used by Julius Caesar.
That is, the letter originally represented by the number p is replaced with the letter
represented by (p + 3) mod 26 in the encrypted version of the message. Note that the function
f is one-to-one, and both its domain and co-domain are given by the set {0, 1, 2, . . ., 25}.
Example 6.5.1
Use Caesar’s cypher to encrypt the word, YARD
Solution:
First, we replace each letter in the word with its corresponding number.
This gives,
Y A R D
24 0 17 3
Now we replace each of these numbers p by f(p) = (p + 3) mod 26. So, we have the
following;
f(24) = (24 + 3) = 27 ≡ 1 mod 26
f(0) = (0 + 3) = 3 ≡ 3 mod 26
9
f(17) = (17 + 3) = 20 ≡ 20 mod 26
f(3) = (3 + 3) = 6 ≡ 6 mod 26.
Now we replace the above numbers with their corresponding letter in the alphabet.
1 3 20 6
B D U G
Thus the encrypted version of the word, YARD is BDUG.
In decrypting a Caesar’s cypher, we need to shift each letter three letters backwards in the
alphabet. For example, the letter E in an encrypted message represents the letter B in the
decrypted version and the letter A in an encrypted message represents the letter X upon
decryption. The mathematical representation of the decryption process is given by the inverse
function of f which assigns to the non-negative integer p in the set {0, 1, 2, . . . , 25}, the non-
negative integer 𝑓 −1 (p) in the set {0, 1, 2, . . . , 25} with 𝑓 −1 (p) = (p - 3) mod 26.
According to the decryption, the letter p in a secret message is replaced with the letter given
by (p - 3) mod 26 in order to derive the original message. Note that 𝑓 −1 exists since f is one-
to-one, and both the domain and co-domain of 𝑓 −1 are given by the set {0, 1, 2, . . . , 25}.
Example 6.5.1
Use Caesar’s cypher to decrypt the word, CHVW.
Solution:
First, we replace each letter in the word with its corresponding number.
This gives,
C H V W
2 7 21 22
Now we replace each of these numbers p by 𝑓 −1 (p) = (p - 3) mod 26. So, we have the
following;
𝑓 −1 (2) = (2 - 3) = -1 ≡ 25 mod 26; (∵ Note that -1 = 26 × (-1) + 25)
𝑓 −1 (7) = (7 - 3) = 4 ≡ 4 mod 26
𝑓 −1 (21) = (21 - 3) = 18 ≡ 18 mod 26
𝑓 −1 (22) = (22 - 3) = 19 ≡ 19 mod 26
10
Now we replace the above numbers with their corresponding letter in the alphabet.
25 4 18 19
Z E S T
Thus the secret word, CHVW means the English word, ZEST in the original message.
Self-Assessment Exercises:
1. Use Caesar’s Cypher to encrypt the following letters,
A, D, G, H, K, Q, R, U, Y, Z.
B, C, F, H, N, P, R, S, U, W.
Suggested Readings:
Chapter 3: Sections 3.4, 3.5, 3.6 & 3.7, Kenneth Rosen, (2011) Discrete Mathematics and Its
Applications, 7th Edition, McGraw-Hill Education
11