0% found this document useful (0 votes)
158 views4 pages

4.7 Notes and Exercises

The Euclidean algorithm is a method for finding the greatest common divisor (GCD) of two integers by recursively finding the remainder of the division of one integer by the other. This process is repeated until the remainder is zero, leaving the GCD. The algorithm can also be used to express the GCD as a linear combination of the two integers. The extended Euclidean algorithm provides a systematic way to derive these coefficients. It sets up a tableau where each row uses the quotient of one number divided by the other to update all values in that row. The last non-zero remainder is the GCD, and the final values in the S and T columns give the coefficients to express the GCD as a linear combination.

Uploaded by

aswaniexpress
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
158 views4 pages

4.7 Notes and Exercises

The Euclidean algorithm is a method for finding the greatest common divisor (GCD) of two integers by recursively finding the remainder of the division of one integer by the other. This process is repeated until the remainder is zero, leaving the GCD. The algorithm can also be used to express the GCD as a linear combination of the two integers. The extended Euclidean algorithm provides a systematic way to derive these coefficients. It sets up a tableau where each row uses the quotient of one number divided by the other to update all values in that row. The last non-zero remainder is the GCD, and the final values in the S and T columns give the coefficients to express the GCD as a linear combination.

Uploaded by

aswaniexpress
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

4.

7 Euclidean algorithm

Greatest common divisor of two integers m and n


is the largest integer d such that m = dq1 and n = dq2.

One way of finding the greatest common divisor uses the prime factorizations:
Example: 84 = 22A3A7 and 60 = 22A3A5. Clearly the gcd(84, 60) = 22A3 = 12
For large numbers this approach may be difficult.

The Euclidean Algorithm uses the fact that the greatest common divisor of two integers must be a factor
of the difference of the integers. If m = nq + r, then the gcd must also divide the remainder r.

Example We will see by the Euclidean Algorithm that gcd(84, 60) = 12:
84 – 60×(1) = 24
60 – 24×(2) = 12
24 – 12×(2) = 0, so gcd(84, 60) = gcd(60, 24) = gcd(24, 12) = gcd(12, 0) = 12

Greatest common divisor as a linear combination


Theorem If a and b are positive integers and gcd(a, b) = d then there are integers s and t such that
d = s×a + t×b.

We illustrate first a method of finding these multipliers s and t by reversing the calculations of the
Euclidean Algorithm. Later we show a direct way of finding s and t using the Extended Euclidean
Algorithm
Rewriting these equations in reverse:
12 = 60 + 24×(-2)
24 = 84 + 60×(-1)
Replacing 24 in the first equation yields 12 = 60 + [84 + 60×(-1)]×(-2) = 84×(-2) + 60×(3).

Example We see by Euclidean Algorithm that gcd (216, 126) = 18


216 – 126×(1) = 90
126 – 90×(1) = 36
90 – 36×(2) = 18
36 – 18×(2) = 0, so gcd(216, 126) = gcd(126, 90) = gcd(90, 36) = gcd(36, 18) = 18

Rewriting these equations in reverse:


18 = 90 + 36×(-2) and 36 = [126 + 90×(-1)] and 90 = [216 + 126×(-1)] and substituting yields:
18 = 90 + [126 + 90×(-1)]×(-2) = 126×(-2) + 90×(3)
= 126×(-2) + [216 + 126×(-1)]×(3) = 216×(3) + 126×(-5).

The Extended Euclidean Algorithm can be used to find the gcd of two numbers and express it as a
linear combination of those numbers. It uses auxiliary numbers 1 and 0 and two starting conditions to
produce an invariant expression G = S×A + T×B that yields the desired result.

As shown in the following example, this invariant


starts with G = 1×A + 0×B which equals A and continues with G = 0×A + 1×B which equals B.
Initially A is integrally divided by B, and the quotient Q is used to obtain the remainder R = A – B*Q.
In the example, Qn = floor ( R(n–2) / R(n–1) ) and A = R(-1) and B = R(0).
New values of S and T and G are obtained in the same way as R; for example, Sn = S(n–2) – S(n–1)*Qn.
The process continues until the last nonzero remainder is found; and that is the gcd(A, B).
Example We can show that gcd(356, 252) = 4 and that 4 = (17)356 + (-24)252
In the following tableau, the first two lines express A and B as linear combinations of themselves. The
calculation begins in the third line where Qn = floor ( R(n–2) / R(n–1) ) and A = R(-1) and B = R(0). Each of
the other columns uses Qn to find the subsequent entry, and the process is repeated for each line.
Specifically, Rn = R(n–2) – R(n–1)*Qn, and Sn = S(n–2) – S(n–1)*Qn, and Tn = T(n–2) – T(n–1)*Qn,
Q R S T G = SA + TB
A 356 1 0 356 = 1A + 0B
B 252 0 1 252 = 0A + 1B
1 104 1 -1 104 = 1 A + (-1)B
2 44 -2 3 44 = (-2)A + 3B
2 16 5 -7 16 = 5A + (-7)B
2 12 -12 17 12 = (-12)A + 17B
1 4 17 -24 4 = 17A + (-24)B
3 0 -63 89

Lemma If a, b, c are positive integers such that gcd(a, b) = 1 and if a | bc, then a | c.
Proof: Set 1 = sa + tb and multiply by c, getting c = sac + tbc.
Since a divides any multiple of itself and any multiple of bc, a | sac and a | tbc, so it must divide c.

Lemma A prime that divides a product of integers must divide at least one of the factors.

From this lemma follows the unique factorization of positive integers.

Another consequence of the lemma is the


Theorem If m is a positive integer and a, b, c are integers such that ac / bc (mod m) and gcd(c, m) = 1,
then a / b (mod m).

Linear Congruences ax / b (mod m)


Note that we may not divide in a modular system, but we can multiply to produce one if we know the
modular inverse. It is possible to find the modular inverse by repeated trials, but the Extended Euclidean
Algorithm may be more efficient when the modulus is large.

To find the modular inverse of 2 (mod 7), consider that gcd(7, 2) = 1 = (1)7 + (-3)2. Reducing this
equation (mod 7), where 0 replaces 7, and 4 replaces (-3) produces 1 / 0 + (4)2 (mod 7). Now to solve
the linear congruence 2x / 5 (mod 7) we multiply by 4, which is the modular inverse of 2 :
8x / 20 (mod 7) which reduces to x / 6 (mod 7).

To find the modular inverse of 3 (mod 13), consider that gcd(13, 3) = 1 = (1)13 + (-4)3. Reducing this
equation (mod 13), where 0 replaces 13, and 9 replaces (-4) produces 1 / 0 + (9)3 (mod 13). Now to
solve the linear congruence 3x / 7 (mod 13) we multiply by 9, which is the modular inverse of 3:
27x / 63 (mod 13) which reduces to x / 11 (mod 13)

To find the modular inverse of 21 (mod 26), consider that gcd(26, 21) = 1 = (-4)26 + (5)21. Reducing
the equation (mod 26), where 0 replaces 26, and 5 stands for itself produces 1 / 0 + (5)21 (mod 26).
Now to solve the linear congruence 21x / 3 (mod 26) we multiply by 5, which is the modular inverse
of 21: 105x / 15 (mod 26) which reduces to x / 15 (mod 26).
4.7 Euclidean Algorithm p178. 1, 3, 5, 7, 9
1. Use any method to find gcd(m, n)
a) gcd(20, 20) = 20 b) gcd(20, 10) = 10 c) gcd(20, 1) = 1 d) gcd(20, 0) = 20
e) gcd(20, 72) = gcd(72, 20 MOD 72) = gcd(72, 20) = gcd(20, 72 MOD 20) = gcd(20, 12)
= gcd(12, 20 MOD 12) = gcd(12, 8) = gcd(8, 12 MOD 8) = gcd(8, 4) = gcd(4, 8 MOD 4) = gcd(4, 0) = 4
f) gcd(20, -20) = gcd( 20, 20) = 20
g) gcd(120, 162) = gcd(162, 120) = gcd(120, 42) = gcd(42, 36) = gcd(36, 6) = gcd(6, 0) = 6
h) gcd(20, 27) = gcd(27, 20) = gcd(20, 7) = gcd(7, 6) = gcd(6, 1) = 1

3. List the pairs (a, b) that arise AlgorithmGCD is applied to the numbers m, n, and find gcd(m, n).
a) gcd(20, 14): (20, 14), (14, 6), (6, 2), (2, 0); gcd(20, 14) = 2
b) gcd(20, 7): (20, 7), (7, 6), (6, 1), (1, 0); gcd(20, 7) = 1
c) gcd(20, 30): (20, 30), (30, 20), (20, 10), (10, 0); gcd(20, 30) = 10
d) gcd(2000, 987): (2000, 987), (987, 26), (26, 25), (25, 1), (1, 0); gcd(2000, 987) = 1

5. Use the Euclidean Algorithm to find gcd(m, n) and integers s and t such that gcd(m, n) = sm + tn.
a) gcd(20, 14) = 2 = (-2)20 + (3)14
a q s t
20 1 0
14 1 0 1
6 2 1 -1
2 3 -2 3
0

b) gcd(72, 17) = 1 = (-4)72 + (17)17


a q s t
72 1 0
17 4 0 1
4 4 1 -4
1 4 -4 17
0

c) gcd(20, 30) = 10 = (-1)20 + (1)30


a q s t
20 1 0
30 0 0 1
20 1 1 0
10 2 -1 1
0

d) gcd(320, 30) = 10 = (-1)320 + (11)30


a q s t
320 1 0
30 10 0 1
20 1 1 -10
10 2 -1 11
0
7. For each value of n solve nAx / 1 (mod 26) with 0 # x # 26 or explain why no solution exists.
a) 5x / 1 (mod 26); gcd(26, 5) = 1 = (-4)26 + (21)5; x = 21
b) 11x / 1 (mod 26); gcd(26, 11) = 1 = (-8)26 + (19)11; x = 19
c) 4x / 1 (mod 26); gcd(26, 4) = 2 … 1 so there is no solution.
d) 9x / 1 (mod 26); gcd(26, 9) = 1 = (-1)26 + (3)9; x = 3
e) 17x / 1 (mod 26); gcd(26, 17) = 1 = (-15)26 + (23)17; x = 23
f) 13x / 1 (mod 26); gcd(26, 13) = 2 … 1 so there is no solution.

9. Solve the following congruence equations for x:


a) 8x / 1 (mod 13); gcd(13, 8) = 1 = (-3)13 + (5)8; x / 5
b) 8x / 4 (mod 13); gcd(13, 8) = 1 = (-3)13 + (5)8; 4 = (-12)13 + (20)8; x / 4A5 = 20 /7 (mod 13)
c) 99x / 1 (mod 13); reduce 99x (mod 13) to 8x, so answer is the same as part a)
d) 99x / 5 (mod 13); x / 5A5 = 25 /12 (mod 13)

You might also like