The Extended Euclidean Algorithm: Finding gcd and Linear Combination of Two Numbers, Study notes of Algorithms and Programming

The extended euclidean algorithm, a method used to find the greatest common divisor (gcd) of two numbers and determine their linear combination. Two examples are provided, one with m = 65 and n = 40, and the other with m = 1239 and n = 735.

Typology: Study notes

2021/2022

Uploaded on 09/12/2022

pierc
pierc 🇺🇸

4.3

(4)

220 documents

1 / 2

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
The Extended Euclidean Algorithm
Example 1: m= 65, n = 40
Step 1: The (usual) Euclidean algorithm:
(1) 65 = 1 ·40 +25
(2) 40 = 1 ·25 +15
(3) 25 = 1 ·15 +10
(4) 15 = 1 ·10 +5
10 = 2 ·5
Therefore: gcd(65,40) = 5.
Step 2: Using the method of back-substitution:
5(4)
=15 10
(3)
=15 (25 15) =2·15 25
(2)
=2(40 25) 25 =2·40 3·25
(1)
=2·40 3(65 40) =5·40 3·65
Conclusion: 65(3)
| {z }
x
+40(5)
| {z }
y
=5.
1
pf2

Partial preview of the text

Download The Extended Euclidean Algorithm: Finding gcd and Linear Combination of Two Numbers and more Study notes Algorithms and Programming in PDF only on Docsity!

The Extended Euclidean Algorithm

Example 1: m = 65, n = 40

Step 1: The (usual) Euclidean algorithm:

(1) 65 = 1 · 40 + 25 (2) 40 = 1 · 25 + 15 (3) 25 = 1 · 15 + 10 (4) 15 = 1 · 10 + 5 10 = 2 · 5

Therefore: gcd(65, 40) = 5.

Step 2: Using the method of back-substitution:

5 (4) = 15 − 10 (3) = 15 − (25 − 15) = 2 · 15 − 25 (2) = 2(40 − 25) − 25 = 2 · 40 − 3 · 25 (1) = 2 · 40 − 3(65 − 40) = 5 · 40 − 3 · 65

Conclusion: 65(︸ −︷︷3) ︸ x

y

The Extended Euclidean Algorithm

Example 2: m = 1239, n = 735

Step 1: The (usual) Euclidean algorithm:

(1) 1239 = 1 · 735 + 504 (2) 735 = 1 · 504 + 231 (3) 504 = 2 · 231 + 42 (4) 231 = 5 · 42 + 21 42 = 2 · 21

Therefore: gcd(1239, 735) = 21.

Step 2: Using the method of back-substitution:

21 (4) = 231 − 5 · 42 (3) = 231 − 5(504 − 2 · 231) = 11 · 231 − 5 · 504 (2) = 11(735 − 504) − 5 · 504 = 11 · 735 − 16 · 504 (1) = 11 · 735 − 16(1239 − 735) = 27 · 735 − 16 · 1239

Conclusion: 1239(︸ −︷︷16) ︸ x

y