Support Ukraine πŸ‡ΊπŸ‡¦Help Ukrainian ArmyHumanitarian Assistance to Ukrainians

Proof of Euclid's Algorithm

Sam

Oct 05 2020 at 12:47 GMT

According to Euclid's Algorithm, the greatest common divisor (gcd) of two integers aa and bb, where b≠0b \ne 0, is equal to the greatest common divisor of bb and the remainder of dividing aa by bb. Symbolically:

gcd⁑(a,b)=gcd⁑(b,rem(a,b)) βˆ€a∈Z,βˆ€b∈Zβ‰ 0\gcd(a, b) = \gcd(b, \text{rem}(a, b)) \ \forall a \in \Z, \forall b \in \Z_{\ne 0}

How can we prove this?

1 Answer

Carl

Oct 05 2020 at 13:55 GMT

Before providing the proof for Euclid's algorithm, there will be a few preliminary definitions, a theorem, and a lemma.

Definition of divides. We say that an integer aa divides an integer bb if and only if aa multiplied by some integer kk is equal to bb:

a∣bβ€…β€ŠβŸΊβ€…β€Šβˆƒk∈Z:ak=ba \mid b \iff \exists k \in \Z : ak =b

The symbol ∣| is a shorthand for divides.

Definition of integer linear combination. An integer linear combination of two integers aa and bb is an expression of the form sa+tbsa+tb, where ss and tt are some integers.

Since we are working with integers, from now on I will refer to integer linear combination as just linear combination.

Division Theorem. Given an integer nn and a non-zero integer dd (the divisor), there exists a unique pair of integers qq (the quotient) and rr (the remainder) with 0≀r<∣d∣0 \le r < \left|d\right| such that nn is equal to the product qdqd plus the remainder rr:

βˆ€n∈Z,βˆ€d∈Zβ‰ 0,βˆƒ!q,r∈Z:n=qd+r with 0≀r<∣d∣\forall n \in \Z, \forall d \in \Z_{\ne 0}, \exists! q, r \in \Z : n = qd + r \text{ with } 0 \le r < \left|d\right|

I will not provide the proof for this theorem, but you can look it up.

Lemma 1. If an integer aa divides an integer bb, and it also divides another integer cc, then aa divides any linear combination of bb and cc:

(a∣b)∧(a∣c)β€…β€ŠβŸΉβ€…β€Ša∣sb+tc  βˆ€s,t∈Z(a \mid b) \land (a \mid c) \implies a \mid sb + tc \ \ \forall s, t \in \Z

Proof of Lemma 1. Assume that a∣ba \mid b and a∣ca\mid{c}. Since a∣ba\mid{b}, there exists an integer k1k_1 such that ak1=bak_1=b. Likewise, since a∣ca\mid{c}, there exists an integer k2k_2 such that ak2=cak_2=c.

Let sb+tcsb+tc be any linear combination of bb and cc. We can rewrite it in terms of aa:

sb+tc=s(ak1)+t(ak2)=a(sk1)+a(tk2)=a(sk1+tk2)\begin{aligned} sb + tc &= s(ak_1) + t(ak_2) \\ &= a(sk_1) + a(tk_2) \\ &= a(sk_1 + tk_2) \end{aligned}

Since aa multiplied by some integer is equal to sb+tcsb+tc, it means that aa divides sb+tcsb+tc.

⬛

Finally, let's get to the proof of Euclid's algorithm, which I restate for convenience:

gcd⁑(a,b)=gcd⁑(b,rem(a,b)) βˆ€a∈Z,βˆ€b∈Zβ‰ 0\gcd(a, b) = \gcd(b, \text{rem}(a, b)) \ \forall a \in \Z, \forall b \in \Z_{\ne 0}

Euclid's algorithm Proof. By the Division Theorem, we know that there exists a unique pair of integers qq and rr such that aa is equal to the product of the quotient qq and bb plus the remainder rr:

βˆƒ!q,r:a=qb+r with 0≀r<∣b∣\exists! q, r: a = qb + r \text{ with } 0 \le r < \left|b\right|

rr is by definition rem(a,b)\text{rem}(a,b). We can express rr in terms of aa and bb by rearranging the above equation:

a=qb+rr=aβˆ’qbr=a+(βˆ’q)brem(a,b)=a+(βˆ’q)b\begin{aligned} a &= qb + r \\ r &= a - qb \\ r &= a + (-q)b \\ \text{rem}(a, b) &= a + (-q)b \end{aligned}

Thus, we found that rem(a,b)\text{rem}(a,b) is a linear combination of aa and bb.

Since gcd⁑(a,b)\gcd(a,b) divides both aa and bb, it also divides any linear combination of aa and bb (by Lemma 1).

Therefore, gcd⁑(a,b)\gcd(a,b) divides rem(a,b)\text{rem}(a,b).

gcd⁑(a,b)∣rem(a,b)\gcd(a, b) \mid \text{rem}(a, b)

This and the fact that gcd⁑(a,b)∣b\gcd(a,b) \mid b tells us that gcd⁑(a,b)\gcd(a,b) is a common divisor of bb and rem(a,b)\text{rem}(a,b), which means that it has to be less than or equal to gcd⁑(b,rem(a,b))\gcd(b, \text{rem}(a, b)):

gcd⁑(a,b)≀gcd⁑(b,rem(a,b))\gcd(a, b) \le \gcd(b, \text{rem}(a, b))

Also, since aa is a linear combination of bb and rem(a,b)\text{rem}(a,b), the gcd⁑(b,rem(a,b))\gcd(b,\text{rem}(a,b)), which divides both bb and rem(a,b)\text{rem}(a,b), must divide aa.

gcd⁑(b,rem(a,b))∣a\gcd(b, \text{rem}(a, b)) \mid a

This means that gcd⁑(b,rem(a,b))\gcd(b,\text{rem}(a,b)) is a common divisor of aa and bb, and so it has to be less than or equal to the greatest common divisor of aa and bb.

gcd⁑(b,rem(a,b))≀gcd⁑(a,b)\gcd(b, \text{rem}(a, b)) \le \gcd(a, b)

Therefore, since gcd⁑(a,b)\gcd(a,b) is less than or equal to gcd⁑(b,rem(a,b)\gcd(b,\text{rem}(a,b) and vice versa, they have to be equal.

gcd⁑(a,b)=gcd⁑(b,rem(a,b))\gcd(a, b) = \gcd(b, \text{rem}(a, b))

⬛

claritician Β© 2022