Definition. Euclidean Algorithm [00F9]

Let a,b \in \mathbb {N}. To find \gcd (a,b), repeatedly apply these rules: \begin {align*} \gcd (a,0) &= a \\ \gcd (a,b) &= \gcd (b, a \mathbin {\mathbf {mod}} b) \end {align*} That is, just keep repeating the second case until reaching the first case. This is guaranteed to stop in a finite amount of time since the second input to \gcd gets smaller with each step; it must hit zero eventually.