Greatest common divisor and the Euclidean Algorithm. - DCU
Greatest common divisor and the Euclidean Algorithm. - DCU
Greatest common divisor and the Euclidean Algorithm. - DCU
You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
The <strong>Euclidean</strong> <strong>Algorithm</strong><br />
with gcd( a, b) = gcd( b, r ) = gcd( r, r ) = gcd( r , r ) = gcd( r , r ) = gcd( r , r ) =<br />
1 1 2 2 3 3 4 4 5<br />
K<br />
This sequence of equations cannot continue indefinitely. Why Because ‘a decreasing sequence<br />
of positive integers must have a least member’. (This is sometimes referred to as <strong>the</strong><br />
Fundamental Property of <strong>the</strong> Natural Numbers’). Here <strong>the</strong> decreasing sequence is r, r , r ,K .<br />
1 2 3<br />
Thus we must eventually arrive at some remainder<br />
r n<br />
such that<br />
rn<br />
rn−1 , <strong>and</strong> so we end up with:<br />
rn−3 = rn−2qn− 1<br />
+ rn− 1, <strong>and</strong> 0< rn− 1<br />
≤ ( rn−2 −1),<br />
qn−<br />
1<br />
∈Z,<br />
rn−2 = rn− 1qn + rn, <strong>and</strong> 0< rn ≤ ( rn−<br />
1<br />
−1),<br />
qn<br />
∈Z,<br />
r = r q , with q ∈ Z . (<strong>and</strong> thus gcd( r , r ) = r .)<br />
n− 1 n n+ 1 n+ 1 n−1<br />
n n<br />
Finally we have: gcd( a, b) = gcd( b, r ) = K = gcd( r , r ) = r , <strong>and</strong> thus: gcd( a, b) = .<br />
1 n−1<br />
n n<br />
That last equation is of fundamental importance as it enables us to calculate - with incredible<br />
speed - <strong>the</strong> greatest <strong>common</strong> <strong>divisor</strong> of any two integers without having to calculate any<br />
<strong>common</strong> <strong>divisor</strong>s at all!! It is a remarkable method due to Euclid (~ 300B.C.), <strong>and</strong> is rightly<br />
considered to be one of <strong>the</strong> very best algorithms (an algorithm - roughly speaking - is a set of<br />
instructions for carrying out a given calculation).<br />
You should do - by h<strong>and</strong> - several worked examples of finding <strong>the</strong> greatest <strong>common</strong> <strong>divisor</strong> of<br />
two integers; examples like:<br />
Find, using <strong>the</strong> <strong>Euclidean</strong> <strong>Algorithm</strong>, g cd( 987, 345), gcd( 12321, 337), gcd( 97, 47),<br />
etc.<br />
Note. Maple has an in-built comm<strong>and</strong> for calculating <strong>the</strong> gcd of any two integers; it is igcd(a,<br />
b). This comm<strong>and</strong> (igcd for calculating <strong>the</strong> gcd of two integers) happens to be one of a very<br />
small number whose Maple code cannot be accessed using <strong>the</strong> interface(verboseproc=2)<br />
(followed by print(igcd)) facility, but you will see in Maple lab classes a simple Maple<br />
procedure for calculating <strong>the</strong> gcd of any two integers.<br />
Ano<strong>the</strong>r very important related Maple comm<strong>and</strong>. There is a related comm<strong>and</strong> igcdex, which<br />
expresses <strong>the</strong> gcd of two integers as an ‘integral linear combination’ of those integers. That is<br />
<strong>the</strong> subject of ano<strong>the</strong>r set of notes.<br />
Proof of Theorem 2. Let f1 ∈S1 <strong>and</strong> f2<br />
∈S2. (We will prove that f1 ∈S2 <strong>and</strong> f2 ∈S1, <strong>and</strong> so it<br />
will follow that S1 = S2.) Since f1 ∈ S1<br />
<strong>the</strong>n a = f1A<strong>and</strong> b=<br />
f1Bfor some AB , ∈Z, <strong>and</strong> so we<br />
have (from a = bq+ r) that fA<br />
1<br />
= ( fBq<br />
1<br />
) + r, <strong>and</strong> thus r = f1A− ( f1B) q = f1( A−<br />
Bq).<br />
Thus f 1<br />
is a<br />
<strong>divisor</strong> of r because ( A− B q) ∈Z,<br />
<strong>and</strong>, since f1<br />
is a <strong>divisor</strong> of b, it follows that f 1<br />
is a <strong>common</strong><br />
<strong>divisor</strong> of b <strong>and</strong> r. Thus every <strong>common</strong> <strong>divisor</strong> of a <strong>and</strong> b is also a <strong>common</strong> <strong>divisor</strong> of b <strong>and</strong> r,<br />
i.e. f<br />
∈ S . ... (i)<br />
1 2<br />
r n<br />
Page 4 of 6