euclidean-algorithm

https://en.wikipedia.org/wiki/Euclidean_algorithm

This algorithm is based on the principle that the greatest common divisor of two numbers does not change if the larger number is replaced by its difference with the smaller number.

For example, 21 is the GCD of 252 and 105 (as 252 = 21 × 12 and 105 = 21 × 5), and the same number 21 is also the GCD of 105 and 252 − 105 = 147.

By reversing the steps, the GCD can be expressed as sum two numbers, i.e. 21 = 5 x 105 + (-2) x 252.

results matching ""

    No results matching ""