Definition. Euclidean Algorithm (simple version) [00HM]

We can put these observations about \gcd together to write down a procedure for computing it. This is one of the oldest recorded algorithms, and is named the Euclidean Algorithm since it is in Euclid's Elements, written in about 300 BC. It was also independently invented in both India and China. This simple version is essentially equivalent to the version found in the Elements, although we will also describe a slightly more efficient version later.

  • \gcd (a,0) = a.
  • If a \geq b, then \gcd (a,b) = \gcd (a-b,b).
  • Otherwise, \gcd (a,b) = \gcd (b,a).

Each of these steps is justified by one of our previous theorems, and a and b keep getting smaller and smaller so b must eventually reach 0.