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

Euclidean Algorithm: by Prof. Dr. Safaa Amin

11 and 26 are not relatively prime, so the multiplicative inverse does not exist modulo 26.

Uploaded by

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

Euclidean Algorithm: by Prof. Dr. Safaa Amin

11 and 26 are not relatively prime, so the multiplicative inverse does not exist modulo 26.

Uploaded by

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

Lecture 8

Euclidean Algorithm
By
Prof. Dr. Safaa Amin
• As the numbers tested get larger, the square root test for primality does have
limitations. The next example illustrates this fact.
• Being able to determine whether large numbers are prime will be important later
on when we study the RSA cryptosystem. To deal with larger numbers, much
more sophisticated tests for primality testing have been developed and are an on
going topic of research.

• The largest prime number discovered up to December 2005 was the number

30402457
2 1
which is a 9152052 digit prime number.
Factorization of Composite Numbers
• Recall that a number that is not prime, it is composite. If a number is composite,
it can be factored into prime factors other than 1 and itself. We review some
basic techniques of factoring in the following examples.
The Greatest Common Divisor of Two Numbers

• Recall that the greatest common divisor of two numbers, denoted as gcd(a, b), is
the largest number that divides a and b evenly with no remainder. For example,
gcd(10, 20). = 10 and gcd(72, 108)=36.
• Previously, we saw a method to find the gcd that involved
multiplying the prime factors that both numbers had in common. This
method is inefficient for find the greatest common divisor of larger
numbers since it is harder factor numbers with larger prime factors.
GCD
• 
a1
a p p
1
a2
2 p an
n
b  p1b1 p2b2  pnbn

gcd( a, b)  p1min(a1 ,b1 ) p2min(a2 ,b2 )  pnmin(an ,bn ) .


Euclidean algorithm

• However, there is a well known method known as the Euclidean


algorithm that will allows us to find the greatest common divisor of
larger numbers which we state next.
Euclidean Algorithm
A Little on Euclid

• Lived from 323 – 285 BC


• He taught in Alexandria, Egypt
• Euclid worked on a team of mathematicians that all contributed in
writing books. The group continued writing these books under
Euclid’s name even after his death.
Euclidean Algorithm
• 
The Euclidean Algorithm

The Euclidean Algorithm makes repeated use of


the division algorithm to find the greatest common
divisor of two numbers. If we are given two
numbers a and b where a > b, we compute
Division Algorithm
Example
a  q1b  r1
b  q2 r1  r2
r1  q3r2  r3
r2  q4 r3  r4

rn  3  qn 1rn  2  rn 1
.
rn  2  qn rn 1  rn  gcd( a, b)
rn 1  qn 1rn  0
The last nonzero remainder, rn , is the greatest common divisor
of a and b, that is, gcd( a, b)  rn
Euclidean Algorithm
• 

• gcd(2322, 654) = gcd(654, 360)


• gcd(654, 360) = gcd(360, 294)
• gcd(360, 294) = gcd(294, 66)
• gcd(294, 66) = gcd(66, 30)
• gcd(66, 30) = gcd(30, 6)

• gcd(30, 6) = 6
• 

 
Theorem

For any two positive integers a and b, there are integers s and t where

as + bt = gcd(a, b)
Note
• To find s and t, we solve for the remainders starting with the first step in the
Euclidean algorithm, substituting each remainder we obtain into the remainders
we obtain in successive steps until the greatest common divisor of a and b is
reached.
Example : Find s and t where
as + bt = gcd(a, b), where a = 2299 and b = 627.

Solution: (next slides)


• 

Stop remainder solving when you reach


  GCD
Example : Compute .

Solution: Solve ;

𝑺=−𝟒 𝒂𝒏𝒅𝒕=𝟐𝟓
Multiplicative Inverse
with (Extended Euclidean
Algorithm)
Corollary
• If a and b are relatively prime (gcd(a, b) = 1), then b has an inverse modulo a.
That is, 1
b MOD a exists. Then

bt = 1 MOD a has a solution . t  b 1


• Using the previous results, we want to consider the problem of solving the
modular equation
bt  1 MOD a
for t. Here, t represents the multiplicative inverse of b MOD a, that is, the
number you must multiply b by to get 1 in MOD a arithmetic. In mathematical
notation, we say that .
t  b 1 MOD a
131 MOD 81
Fact
1 is computed by solving as + bt = 1. To ensure t > 0,
t b
compute t = t MOD a to convert t to its positive representation.
Example : Compute .

Solution: Solve ;

𝑺=−𝟒 𝒂𝒏𝒅𝒕=𝟐𝟓
Example 15: Compute 29 1 MOD 83.
Solution:
step 1: run Euclidean algorithm on 2- Solve for the remainder

=>
convert to positive hence =63
To verify this answer =>
Example 16: Solve 7x + 1 = 4 MOD 26 for x.

Solution: We must first isolate x on one side of


the equation.

7 x  1  4 MOD 26
7x  3 MOD 26
1
x  (7  3) MOD 26
1
To finish this problem, we need to find 7. MOD 26
We want to solve where a = 26 and b = 7. To find s and t, we perform the Euclidean
algorithm on a and b and perform the remainder
substitution process.

26  3  7  5  5  26  3  7  a  3b
7  1  5  2  2  7  5  b  ( a  3b)  b  a  3b   a  4b
5  2  2  1  1  5  2  2  ( a  3b)  2(  a  4b)  a  3b  2a  8b  3a  11b
2  2 1  0
Hence, a(3) + b(-11) =1 and thus t = -11. Since t
is negative, we convert it to positive form by
computing t = t MOD a = -11 MOD 26 = 15.
Thus,
1 1
b 7  t  15.
We can check our answer
by computing

1
bb MOD a  (7)(15) MOD 26  104 MOD 26  1

Completing the above problem, we have


1
x  (7  3) MOD 26  (15  3) MOD 26  45 MOD 26  19.
Note
• If
gcd( a, b)  1 , then

1
b MOD a does not exist.
Example 17: Compute 12 1 .MOD 40

Solution:

Then 12 1 MOD 40 does not exist.


Multiplicative Inverse
with (EEA)
Team Members:
1- Ahmed Ashraf Shams
2- Mohamed Ismail Abdellatif
3- Zeyad Ahmed Shokry
Multiplicative Inverse:
Multiplicative Inverse:

• 
Multiplicative Inverse:

Example1: What is the Multiplicative inverse of 11 mod 13?


Multiplicative Inverse
using (EEA):

Example1: What is the Multiplicative inverse of 11 mod 13?


Multiplicative Inverse using (EEA):

Example2: What is the Multiplicative inverse of 11 mod 26?


Multiplicative Inverse
using (EEA):

Example2: What is the Multiplicative inverse of 11 mod 26?

You might also like