Lamé's theorem

Lamé's Theorem is the result of Gabriel Lamé's analysis of the complexity of the Euclidean algorithm. Using Fibonacci numbers, he proved in 1844 that when looking for the greatest common divisor (GCD) of two integers a and b, the algorithm finishes in at most 5k steps, where k is the number of digits (decimal) of b.

Statement
The number of division steps in Euclidean algorithm with entries $$u\,\!$$ and $$v\,\!$$ is less than $$5$$ times the number of decimal digits of $$\min(u,v)\,\!$$.

Proof
Let $$u>v$$ be two positive integers. Applying to them the Euclidean algorithm provides two sequences $$(q_1,\ldots, q_{n})$$ and $$(v_2,\ldots, v_{n})$$ of positive integers such that, setting $$v_0=u,$$ $$v_1=v$$ and $$v_{n+1}=0,$$ one has
 * $$v_{i-1}=q_iv_i +v_{i+1}$$

for $$i=1,\ldots, n,$$ and
 * $$u>v>v_2>\cdots >v_{n}>0.$$

The number $n$ is called the number of steps of the Euclidean algorithm, since it is the number of Euclidean divisions that are performed.

The Fibonacci numbers are defined by $$F_0=0,$$ $$F_1=1,$$ and
 * $$F_{n+1}=F_n+F_{n-1}$$

for $$n>0.$$

The above relations show that $$v_{n}\ge 1=F_2,$$ and $$v_{n-1}\ge 2=F_3.$$ By induction,
 * $$\begin{align}

v_{n-i-1}&=q_{n-i}v_{n-i}+v_{n-i+1}\\ &\ge v_{n-i}+v_{n-i+1}\\ &\ge F_{i+2}+F_{i+1} =F_{i+3}. \end{align}$$ So, if the Euclidean algorithm requires $n$ steps, one has $$v\ge F_{n+1}.$$

One has $$F_{k}\ge \varphi^{k-2}$$ for every integer $$k>2$$, where $\varphi=\frac {1+\sqrt 5}2$ is the Golden ratio. This can be proved by induction, starting with $$F_2 =\varphi^0=1,$$ $$F_3=2> \varphi, $$ and continuing by using that $$\varphi^2=\varphi +1:$$
 * $$\begin{align}

F_{k+1}&=F_k+F_{k-1}\\ &\ge \varphi^{k-2}+\varphi^{k-3}\\ &=\varphi^{k-3}(1+\varphi)\\ &=\varphi^{k-1}. \end{align}$$

So, if $n$ is the number of steps of the Euclidean algorithm, one has
 * $$v\ge \varphi^{n-1},$$

and thus
 * $$n-1 \le \frac {\log_{10} v}{\log_{10} \varphi}< 5\log_{10} v,$$

using $\frac 1{\log_{10} \varphi}<5.$

If $k$ is the number of decimal digits of $$v$$, one has $$v<10^k$$ and $$\log_{10} v<k.$$ So,
 * $$n-1<5k,$$

and, as both members of the inequality are integers,
 * $$n\le 5k,$$

which is exactly what Lamé's theorem asserts.

As a side result of this proof, one gets that the pairs of integers $$(u,v)$$ that give the maximum number of steps of the Euclidean algorithm (for a given size of $$v$$) are the pairs of consecutive Fibonacci numbers.