Section 1.2
Euclid's algorithm
The gcd of two integers
a
and
b
(which, for simplicity, we assume to be positive) can be determined with Euclid's algorithm.
Euclid's algorithm
Input: two positive integers
a
and
b
.
Output: the gcd of
a
and
b
.
Replace (simultaneously)
a
by
b
and
b
by the remainder of the division of
a
by
b
.
Repeat Step 1 until
b
is equal to 0.
Return
a
.
>>>
Proof
Gapplet
Exercise
Remark