For any non-negative integer a and any positive integer b, gcd(a, b) = gcd(b, a mod b)
Euclid(a,b) ; second argument is strictly decreasing 1 if b = 0 2 then return a 3 else return Euclid(b, a mod b)
Let a = 2322, b = 654. 2322 = 654*3 + 360 gcd(2322,654) = gcd(654,360) 654 = 360*1 + 294 gcd(654,360) = gcd(360,294) 360 = 294*1 + 66 gcd(360,294) = gcd(294,66) 294 = 66*4 + 30 gcd(294,66) = gcd(66,30) 66 = 30*2 + 6 gcd(66,30) = gcd(30,6) 30 = 6*5 gcd(30,6) = 6 gcd(6,0) = 6 (Elementary property of gcd) Therefore, gcd(2322,654) = 6.
Euclidean Algorithm Applet