You are on page 1of 23

2023

Number Theory Part 2


IF2303 – Discrete Structure
BACK NUMBER THEORY 01

Overview
Part 7: Number Theory Part 2. This chapter provides an in-depth exploration of various
fundamental concepts in number theory. It delves into modular exponentiation, a crucial
technique for efficiently computing large powers in modular arithmetic. The chapter also
focuses on the study of primes, discussing their unique characteristics and importance in
encryption algorithms and other areas. Furthermore, it explores the concepts of greatest
common divisors and least common multiples.
BACK NUMBER THEORY 02

Objectives
After completing this chapter, you should be able to :
• Employ modular exponentiation as a crucial technique for efficiently computing large powers
in modular arithmetic.
• Appreciate the significance of prime numbers in encryption algorithms and other relevant
areas.
• Apply knowledge of greatest common divisors and least common multiples to solve related
mathematical problems.
BACK NUMBER THEORY 03

• Modular Exponentiation
Content
• Primes
• Greatest Common Divisors
• Least Common Multiples
BACK NUMBER THEORY 25

Modular Exponentiation
BACK NUMBER THEORY 26

Modular Exponentiation
• In cryptography it is important to be able to find b n mod m efficiently
without using an excessive amount of memory, where b, n, and m are
large integers.
• It is impractical to first compute bn and then find its remainder when
divided by m, because bn can be a huge number and we will need a huge
amount of computer memory to store such numbers.
• Instead, we can avoid time and memory problems by using an algorithm
that employs the binary expansion of the exponent n.
BACK NUMBER THEORY 27

Modular Exponentiation Algorithm

Example :
Find 3644 mod 645.
BACK NUMBER THEORY 28

Modular Exponentiation Algorithm


Solution :
The Algorithm initially sets x = 1 and power = 3 mod 645 = 3. In the
j
computation of 3 mod 645, this algorithm determines 3 mod 645 for j =
644 2

1, 2, … , 9 by successively squaring and reducing modulo 645. If a j = 1 (where


aj is the bit in the jth position in the binary expansion of 644, which is
j
(1010000100)2), it multiplies the current value of x by 3 mod 645 and
2

reduces the result modulo 645.

Here are the steps used :


BACK NUMBER THEORY 29

Modular Exponentiation Algorithm

This shows that following the steps of the Algorithm produces the result 3 644 mod 645 = 36.
BACK NUMBER THEORY 30

Primes
BACK NUMBER THEORY 31

Primes
• Every integer greater than 1 is divisible by at least two integers, because a
positive integer is divisible by 1 and by itself. Positive integers that have
exactly two different positive integer factors are called primes.
• A positive integer that is greater than 1 and is not prime is called
composite.
BACK NUMBER THEORY 32

Primes
Example :
The integer 7 is prime because its only positive factors are 1 and 7, whereas
the integer 9 is composite because it is divisible by 3.
BACK NUMBER THEORY 34

Greatest Common Divisors


BACK NUMBER THEORY 35

Greatest Common Divisors


• The largest integer that divides both of two integers is called the greatest
common divisor of these integers.
• Let a and b be integers, not both zero. The largest integer d such that d ∣
a and d ∣ b is called the greatest common divisor of a and b. The greatest
common divisor of a and b is denoted by gcd(a, b).
BACK NUMBER THEORY 36

Greatest Common Divisors


Example :
What is the greatest common divisor of 24 and 36?

Solution :
The positive common divisors of 24 and 36 are 1, 2, 3, 4, 6, and 12. Hence,
gcd(24, 36) = 12
BACK NUMBER THEORY 37

The Euclidean Algorithm


• Computing the greatest common divisor of two integers directly from the
prime factorizations of these integers is inefficient.
• The reason is that it is time-consuming to find prime factoriza- Links tions.
• We will give a more efficient method of finding the greatest common
divisor, called the Euclidean algorithm.
BACK NUMBER THEORY 38

The Euclidean Algorithm


1. Start with two integers A and B for which you want to find the GCD.
2. Perform the replacement steps repeatedly until B becomes zero :
As long as B is not equal to 0, follow these steps:
• Calculate the remainder of dividing A by B (A mod B).
• Replace A with B.
• Replace B with the remainder of the division (A mod B).
3. When B becomes zero, A is the GCD of A and B.
BACK NUMBER THEORY 39

The Euclidean Algorithm


Example :
Find the Greatest Common Divisor (GCD) of two numbers 91 and 287.

Solution :
A = 287, B = 91
287 mod 91 = 14; A = 91, B = 14
91 mod 14 = 7; A = 14, B = 7
14 mod 7 = 0; A = 7, B = 0

Since B has become zero, the GCD of 91 and 287 is 7.


BACK NUMBER THEORY 40

Least Common Multiples


BACK NUMBER THEORY 41

Least Common Multiples


• Prime factorizations can also be used to find the least common multiple
of two integers.
• The least common multiple of the positive integers a and b is the smallest
positive integer that is divisible by both a and b. The least common
multiple of a and b is denoted by lcm(a, b).
BACK NUMBER THEORY 42

Least Common Multiples


Example :
What is the least common multiple of 233572 and 2433?

Solution :
We have
lcm(233572, 2433) = 2max(3, 4)3max(5, 3)7max(2, 0) = 243572
BACK NUMBER THEORY 34

Unit Summary
You should now be able to :
• Employ modular exponentiation as a crucial technique for efficiently computing large powers
in modular arithmetic.
• Appreciate the significance of prime numbers in encryption algorithms and other relevant
areas.
• Apply knowledge of greatest common divisors and least common multiples to solve related
mathematical problems.
Question & Answer

BACK 2023

You might also like