foo=bar

alternate linked content

Main Page

Potatoes

Non existing page

Media:Foo.jpg

Link text

http://example.com

Link content

ISBN 978-1413304541

RFC 1945

PMID 20610307

HTML entities

 

Display space

 

Unsupported Elements

Procedure

[edit]
\n

The Euclidean algorithm can be thought of as constructing a sequence of non-negative integers that begins with the two given integers and and will eventually terminate with the integer zero: with . The integer will then be the GCD and we can state . The algorithm indicates how to construct the intermediate remainders via division-with-remainder on the preceding pair by finding an integer quotient so that:

\n\n
\n\n

Because the sequence of non-negative integers is strictly decreasing, it eventually must terminate. In other words, since for every , and each is an integer that is strictly smaller than the preceding , there eventually cannot be a non-negative integer smaller than zero, and hence the algorithm must terminate. In fact, the algorithm will always terminate at the n-th step with equal to zero.[15]

\n\n

To illustrate, suppose the GCD of 1071 and 462 is requested. The sequence is initially and in order to find , we need to find integers and such that:

\n\n
.
\n\n

This is the quotient since . This determines and so the sequence is now . The next step is to continue the sequence to find by finding integers and such that:

\n\n
.
\n\n

This is the quotient since . This determines and so the sequence is now . The next step is to continue the sequence to find by finding integers and such that:

\n\n
.
\n\n

This is the quotient since . This determines and so the sequence is completed as as no further non-negative integer smaller than can be found. The penultimate remainder is therefore the requested GCD:

\n\n
\n\n

We can generalize slightly by dropping any ordering requirement on the initial two values and . If , the algorithm may continue and trivially find that as the sequence of remainders will be . If , then we can also continue since , suggesting the next remainder should be itself, and the sequence is . Normally, this would be invalid because it breaks the requirement but now we have by construction, so the requirement is automatically satisfied and the Euclidean algorithm can continue as normal. Therefore, dropping any ordering between the first two integers does not affect the conclusion that the sequence must eventually terminate because the next remainder will always satisfy and everything continues as above. The only modifications that need to be made are that only for , and that the sub-sequence of non-negative integers for is strictly decreasing, therefore excluding from both statements.

\n\n