Understand the Euclidean algorithm as a method to efficiently compute the greatest common divisor of two integers.
Euclid's algorithm calculates the greatest common divisor (GCD) of two integers without factoring them into primes. It is one of the oldest algorithms still in use and is used to simplify fractions, solve congruences, and compute modular inverses [1].
The GCD does not change if the larger number is replaced by its remainder when divided by the smaller: $\mathrm{GCD}(a, b) = \mathrm{GCD}(b, a \bmod b)$. This is repeated until the remainder is zero; the last nonzero remainder is the GCD [1][2].
For $a = 252$ and $b = 105$: $252 = 2 \cdot 105 + 42$, then $105 = 2 \cdot 42 + 21$, then $42 = 2 \cdot 21 + 0$. The GCD is $21$ (calculation). The same result is obtained for $1071$ and $462$ (calculation). The least common multiple follows from $\mathrm{lcm}(a, b) = ab / \mathrm{GCD}(a, b)$: here $252 \cdot 105 / 21 = 1260$ (calculation).
By retracing the steps, the GCD can be expressed as a linear combination: $21 = 105 - 2 \cdot 42 = 105 - 2(252 - 2 \cdot 105) = 5 \cdot 105 - 2 \cdot 252$ (calculation). Therefore, there exist integers $x, y$ such that $ax + by = \mathrm{GCD}(a, b)$. When the GCD is $1$, $x$ is the inverse of $a$ modulo $b$: this is the way to derive the private key in RSA (see the line on RSA).
The worst case occurs with consecutive Fibonacci numbers (Lamé's theorem): the number of divisions is proportional to $\log b$, so the algorithm is very fast even for numbers with hundreds of digits (general observation).
Simplification of fractions, solving linear Diophantine equations, calculation of inverses in modular arithmetic (see the line on congruences), cryptography, and polynomial algebra, where the same procedure applies with division between polynomials [1][3].
The algorithm computes the GCD but does not provide the factorization. For small numbers, prime factorization may be more straightforward, but it does not work well for large numbers, where Euclid's algorithm remains efficient (general observation).
[1] Wikipedia (it): Algoritmo di Euclide
[2] Wikipedia (en): Euclidean algorithm
[3] Wikipedia (en): Bézout's identity
Generating summary…