The greatest common divisor is the largest positive integer dividing both inputs:
This maximum exists because belongs to the set and all its elements are at most .
Write using the Euclidean division. If and , then . Conversely, if and , then . Therefore and have exactly the same positive common divisors, proving
For , this agrees with .
Set . At each iteration with , compute the remainder , then set
Stop at the first index with and return . The positive second coordinates strictly decrease, so algorithm termination follows from the well-ordering principle. The equality of greatest common divisors established in (ii) is a loop invariant, and at termination it gives

Articles by others on the same topic (0)

There are currently no matching articles.