2

Show for all $~n ∈ \mathbb Z^+~$ that if $~a < 2^n~$, then the Euclidean algorithm applied to $~a,~ b~$ with $~b > a~$ will terminate in at most $~2n − 1~$ steps.

So I spoke to my professor and he said to consider that if we begin with a remainder of $~r_1~$ and then consider the remainder from the second iteration $~r_2~$ to compare the value of $~r_2~$ to the initial size of $~a~$.

I'm not really looking for a complete proof, I just kind of need guidance on how to begin looking at this problem.

I'm still new to mathematical proofs so I just need to get a feeling for how to structure this proof or maybe a general guiding clue.

nmasanta
  • 9,222
  • Basically the question is, how much smaller is b%a than a? The answer can be "just barely", but whenever that happens the next step dramatically reduces the size of the problem. On the other hand, it the answer is "a lot" then this step itself dramatically reduces the size of the problem. What's the worst case for the problem size reduction in the course of two steps? – Ian Sep 04 '19 at 02:08
  • Can you show that $r_2 \le \frac a2$? If you can show this, can you finish the problem? – Greg Martin Sep 04 '19 at 02:08

1 Answers1

5

Let us define:

$$a_0=a<b=b_0$$

$$a_{n+1}=(b_n\bmod a_n)$$

$$b_{n+1}=a_n$$

There is actually an improved bound you can get by observing the worst case scenario where $a_{n+1}=b_n-a_n$ on every step. By subsituting $b_n=a_{n-1}$, one reaches the formula:

$$a_{n-1}=a_n+a_{n+1}$$

which is the Fibonacci sequence in reverse! That is to say, the the Euclidean algorithm runs slowest in the case of $a=F_n<F_{n+1}=b$ and takes $n$ steps. Since we know that $F_n\ge\varphi^n/\sqrt5$, it follows that the Euclidean algorithm takes $\lceil\log_\varphi(\sqrt5\min\{a,b\})\rceil$ steps in the worst case, where $\varphi=\frac{1+\sqrt5}2$ is the golden ratio.

In your case specifically, we know that it will take less than $\left\lceil n\log_\varphi(2)+\frac12\log_\varphi(5)\right\rceil\approx\lceil1.44n+1.67\rceil$ steps.