The highest common factor between two integers is the biggest number that divides both.
Example
For example, if we have
The divisors of
The divisors of
The numbers that divide either
Nevertheless, calculating the highest common factor between two numbers can turn out to be much more complicated for very big numbers.
To do so, a method exists which is known as algorithm of Euclides, which, although at first it looks a little bit strange at first, after practiced, it turns out to be much simpler than other methods.
Furthermore, it is also useful for solving diophantine equations.
The Euclides algorithm is based on the definition of three sequences of numbers: the first one is called
The Euclides algorithm consists in doing the following steps:
-
Two numbers are taken:
, . We want to calculate (the highest common factor between and ). For example, we might take and . -
We define:
For example with and , we would have: : -
For
, we do the integer division of by . We call the result and to the remainder . In the previous example, if we want to calculate and (that is to say, ) it is necessary to do the integer division between and . It is clear that the result of the divisón is with remainder , and therefore we write and . -
Now, we define:
In the previous example we had: - When there is one
, then we have (that is to say, that of the previous step!). Furthermore, it is also satisfied that: ( and are also those of the previous step).
Returning to the example that we used on the previous steps, we have seen that for
Besides, the last equality says to us that: