How does the Euclidean algorithm find the greatest common divisor of two numbers?

Created from Britannica articles using AI. AI can make mistakes, so verify using Britannica articles.

The Euclidean algorithm is a procedure for finding the greatest common divisor (GCD) of two numbers. While the term "Euclidean" is most famously associated with Euclidean geometry—the study of plane and solid figures based on axioms and theorems—the algorithm itself is an arithmetic method described by Euclid in his Elements.12

The algorithm functions through successive division and the calculation of remainders:

  • Divide the first number by the second and note the remainder.
  • Replace the first number with the second, and the second number with the remainder obtained in the previous step.
  • Repeat this process until the remainder is 0.
  • The last nonzero remainder is the GCD.1

For example, to find the GCD of 56 and 12:
1. 56=4×12+8
2. 12=1×8+4
3. 8=2×4+0

Since the remainder is now 0, the last nonzero remainder, 4, is the GCD.1