Given two numbers $a$ and $b$, assume $a \leq b$, we perform the following operation.
- If $a = 0$, break else goto step 2
- Assign to $a$ the remainder of $b$ when divided by a, i.e. $$a :=(b \mod a)$$
I want to find the upper bound for the number of iteration given any numbers with some finite digits. Lets assume both have maximum 10 digits. Even better if we find the bound for any given input with any number of digits(generalized upper bound).
We know that the remainder always decreases by at least 1 so this is a trivial upper bound O(a). Lets find something more smart.
Note: This can be also defined as recurrence relation shown below: $$ f(n)=\begin{cases} 0, &\text{ if }n = 0\\ f(a\mod n)+1,&\text{ if }n > 0 \end{cases} $$
We need to find the maximum value possible for the function $f$ for any given value $a$ over all possible $n$.
@lulu
– Nov 28 '22 at 13:39