Skip to main content

Euclidean Algorithm

Definition​

The Euclidean Algorithm is a method for finding the greatest common divisor (GCD) of two integers. It relies on the principle that the GCD of two numbers remains the same if the larger number is replaced by its difference with the smaller number. This process continues until one of the numbers becomes zero, at which point the other number is the GCD

Practice​

euclideanAlgorithm(a, b)
while b is not zero
temp := b
b := a % b
a := temp
return a