Skip to main content

SimpleEuAlgDem

Euclidean Algorithm

Find the Greatest Common Divisor (GCD) step by step

How the Euclidean Algorithm Works

The Euclidean algorithm finds the Greatest Common Divisor (GCD) of two integers by repeatedly applying the division algorithm:

  1. Given non-negative two numbers aa and bb, ensure aba \ge b
  2. If b=0b = 0, then gcd(a,b)=a\gcd(a, b) = a
  3. Otherwise, replace aa with bb and bb with amodba \mod b
  4. Repeat until b=0b = 0