Lamé's theorem explained

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[1] [2] 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.[3] [4]

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

(q1,\ldots,qn)

and

(v2,\ldots,vn)

of positive integers such that, setting

v0=u,

v1=v

and

vn+1=0,

one has

vi-1=qivi+vi+1

for

i=1,\ldots,n,

and

u>v>v2>>vn>0.

The number 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

F0=0,

F1=1,

and

Fn+1=Fn+Fn-1

for

n>0.

The above relations show that

vn\ge1=F2,

and

vn-1\ge2=F3.

By induction,

\begin{align} vn-i-1&=qn-ivn-i+vn-i+1\\ &\gevn-i+vn-i+1\\ &\geFi+2+Fi+1=Fi+3. \end{align}

So, if the Euclidean algorithm requires steps, one has

v\geFn+1.

One has

Fk\ge\varphik-2

for every integer

k>2

, where \varphi=\frac 2 is the Golden ratio. This can be proved by induction, starting with

F2=\varphi0=1,

F3=2>\varphi,

and continuing by using that

\varphi2=\varphi+1:

\begin{align} Fk+1&=Fk+Fk-1\\ &\ge\varphik-2+\varphik-3\\ &=\varphik-3(1+\varphi)\\ &=\varphik-1. \end{align}

So, if is the number of steps of the Euclidean algorithm, one has

v\ge\varphin-1,

and thus

n-1\le

log10v
log10\varphi

<5log10v,

using \frac 1<5.

If is the number of decimal digits of

v

, one has

v<10k

and

log10v<k.

So,

n-1<5k,

and, as both members of the inequality are integers,

n\le5k,

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.

Bibliography

Notes and References

  1. Lamé . Gabriel . 1844 . Note sur la limite du nombre des divisions dans la recherche du plus grand commun diviseur entre deux nombres entiers . Comptes rendus des séances de l'Académie des Sciences . French . 19 . 867–870.
  2. Shallit . Jeffrey . 1994-11-01 . Origins of the analysis of the Euclidean algorithm . Historia Mathematica . en . 21 . 4 . 401–419 . 10.1006/hmat.1994.1031 . 0315-0860. free .
  3. Web site: Weisstein . Eric W. . Lamé's Theorem . 2023-05-09 . mathworld.wolfram.com . en.
  4. Web site: Lame's Theorem - First Application of Fibonacci Numbers . 2023-05-09 . www.cut-the-knot.org.