While testing gcd
function I ended up needing to know a termination bound
for gcd m n
, so had to investigate how many steps the recursion took.
The case I tested was for gcd 7 5
- it had enough steps. The defintion
for gcd
follows the euclidean algorithm, which reduces gcd a b
to gcd b c
for a smaller c
. At each stage, this reduction is simply c = a rem b
Algorithm terminates in 4 steps: