Algorithm. Iterative Euclidean Algorithm [00K5]

The second implementation of the Euclidean Algorithm is iterative:

\mathsf {GCDI}(m,n) =
a \gets m
b \gets n
\mathsf {while} (a \neq 0) \mathsf {and} (b \neq 0):
\mathsf {if} a \leq b:
b \gets b \bmod a
\mathsf {else}:
a \gets a \bmod b
\mathsf {if} a = 0 \mathsf {then} \mathsf {return} b \mathsf {else} \mathsf {return} a