Euclidean Algorithm

An efficient method for computing the greatest common divisor (GCD) of two integers by repeated division and remainder operations.

Method

gcd(a, b) = gcd(b, a mod b) until remainder is zero; the last non-zero remainder is the GCD. Extended Euclidean algorithm also finds integer coefficients x, y such that ax + by = gcd(a, b).

Applications

RSA key generation and modular inverse computation, fraction simplification, cryptographic protocols, computer algebra systems, calendar calculations.

Advantages

Extremely efficient (logarithmic number of steps); foundational; simple to implement; extended form is indispensable in cryptography.

Limitations

Primarily for integers (polynomial analogs exist); performance degrades for very large integers without fast division; not directly applicable to non-Euclidean domains.

Alternatives

Binary GCD (Stein's algorithm), Lehmer's GCD, hardware-accelerated big-integer libraries.

Example

gcd(252,105): 252 mod 105=42; 105 mod 42=21; 42 mod 21=0 -> GCD 21.

Sources

Educational reference only, not professional advice.

All algorithms