Lamé's theorem is a result in number theory and algorithm analysis that provides an upper bound on the number of division steps required by the Euclidean algorithm to compute the greatest common divisor (GCD) of two positive integers. The theorem states that the number of division steps performed by the Euclidean algorithm on inputs $a$ and $b$ (with $a \ge b > 0$) does not exceed five times the number of decimal digits of $b$; equivalently, the number of steps is bounded by a constant multiple of the logarithm of the smaller input.
Formal statement
Let $a$ and $b$ be positive integers with $a \ge b$. If the Euclidean algorithm is applied to the pair $(a,b)$, the number of division (or remainder) steps required to reach the GCD is at most
$$ \left\lfloor \frac{\log_{\phi} b}{\log_{\phi} 10} \right\rfloor + 1, $$
where $\phi = \frac{1+\sqrt{5}}{2}$ (the golden ratio). In decimal notation this inequality implies that the number of steps is less than five times the number of decimal digits of $b$.
Proof sketch
The proof relies on the observation that the worst‑case inputs for the Euclidean algorithm are consecutive Fibonacci numbers. If the algorithm encounters a pair $(F_{k+1}, F_{k})$ of successive Fibonacci numbers, each division step reduces the pair to the previous two Fibonacci numbers, generating the maximal possible number of steps for a given magnitude of the smaller argument. Because Fibonacci numbers grow exponentially with ratio $\phi$ (i.e., $F_{k} \approx \phi^{k}/\sqrt{5}$), the index $k$ of the largest Fibonacci number not exceeding $b$ satisfies
$$ k \approx \log_{\phi} b. $$
Since each step of the Euclidean algorithm corresponds to moving from $F_{k+1}$ to $F_{k}$, the total number of steps is at most $k$. Converting the logarithm base from $\phi$ to base $10$ yields the decimal‑digit bound cited above.
Historical context
The theorem is named after the French mathematician Gabriel Lamé (1795–1870), who published the result in 1844 while studying the efficiency of the Euclidean algorithm. Lamé’s analysis was an early contribution to the field of computational complexity, demonstrating that a classical algorithm has a provably linear bound relative to the size of its input measured in digits.
Significance and applications
- Complexity analysis – Lamé's theorem provides a concrete worst‑case runtime guarantee for the Euclidean algorithm, showing that its time complexity is $O(\log \min(a,b))$ when each arithmetic operation on integers of size $n$ bits is considered unit cost.
- Cryptography – Many cryptographic protocols (e.g., RSA key generation) rely on rapid computation of GCDs; Lamé's bound assures that the Euclidean algorithm remains efficient even for very large integers.
- Algorithm design – The theorem motivates the development of variants such as the binary GCD algorithm and sub‑quadratic GCD algorithms, which aim to improve practical performance while preserving the same asymptotic bound.
Related concepts
- Euclidean algorithm – The classic method for computing the greatest common divisor of two integers.
- Fibonacci numbers – The sequence $F_0 = 0, F_1 = 1, F_{n+2}=F_{n+1}+F_n$; they provide worst‑case inputs for the Euclidean algorithm.
- Complexity classes – Lamé's theorem is an early example of bounding the worst‑case time of an algorithm, a central topic in computational complexity theory.
References
- Lamé, G. (1844). Mémoire sur la théorie des divisions successives. Journal de Mathématiques Pures et Appliquées.
- Knuth, D. E. (1997). The Art of Computer Programming, Volume 2: Seminumerical Algorithms (3rd ed.). Addison‑Wesley.
- Hardy, G. H., & Wright, E. M. (2008). An Introduction to the Theory of Numbers (6th ed.). Oxford University Press.