Calculate GCD and LCM with Euclidean algorithm visualization
The Greatest Common Divisor (GCD) is the largest positive integer that divides all given numbers without remainder.
Example: GCD(12, 18) = 6 because 6 is the largest number that divides both 12 and 18.
The Least Common Multiple (LCM) is the smallest positive integer that is divisible by all given numbers.
Example: LCM(12, 18) = 36 because 36 is the smallest number divisible by both 12 and 18.
The Euclidean algorithm repeatedly replaces the larger number with the remainder of dividing the larger by the smaller, until the remainder is 0.
Steps for GCD(48, 18):
The Extended Euclidean Algorithm finds integers x and y (Bézout coefficients) such that:
a × x + b × y = GCD(a, b)
This is used in cryptography, modular arithmetic, and solving Diophantine equations.
Also known as Stein's algorithm, it computes GCD using bit operations (shift and subtract) instead of division, making it faster on modern computers.
It uses the properties:
Apply the algorithm iteratively:
GCD(a, b, c) = GCD(GCD(a, b), c)
LCM(a, b, c) = LCM(LCM(a, b), c)
Both GCD and LCM are associative, so the order doesn't matter.