structural:expansion, information:extraction
Euclid's algorithm

The method introduced by Euclid for computing greatest common divisors is based on the fact that, given two positive integers a and b such that a > b, the common divisors of a and b are the same as the common divisors of a – b and b.

So, Euclid's method for computing the greatest common divisor of two positive integers consists of replacing the larger number with the difference of the numbers, and repeating this until the two numbers are equal: that is their greatest common divisor.

For example, to compute gcd(48,18), one proceeds as follows:

So gcd(48, 18) = 6.

This method can be very slow if one number is much larger than the other. So, the variant that follows is generally preferred.