On this page
Euclid's method for the HCF is simple: divide, keep the remainder, repeat. A sharper question is how many divisions it can take. In 1844 the French engineer and mathematician Gabriel Lamé gave an answer that depends only on how many digits the numbers have, not on how big they are.
What does Lamé's theorem say?
Gabriel Lamé (1795–1870) studied at the École Polytechnique and the École des Mines, and later held the chair of physics at the Polytechnique (MacTutor biography). His result appeared as a short note in the Comptes rendus of the Paris Academy of Sciences, volume 19, page 867, in 1844, as listed in Jeffrey Shallit's history of the problem in Historia Mathematica.
Lamé's theorem: the Euclidean algorithm never needs more division steps than five times the number of decimal digits of the smaller number (Wikipedia, Euclidean algorithm).
One step is one division with remainder, including the last one, which leaves remainder 0. So for two numbers below 1,000 the smaller one has at most 3 digits, and the algorithm stops within 15 divisions.
Why are consecutive Fibonacci numbers the worst case?
The worst case, when the inputs are consecutive Fibonacci numbers, was studied by Émile Léger in 1837 (Wikipedia). Take F₁₃ = 233 and F₁₂ = 144 (with F₁ = F₂ = 1) and run the algorithm:
233 = 1 × 144 + 89
144 = 1 × 89 + 55
89 = 1 × 55 + 34
55 = 1 × 34 + 21
34 = 1 × 21 + 13
21 = 1 × 13 + 8
13 = 1 × 8 + 5
8 = 1 × 5 + 3
5 = 1 × 3 + 2
3 = 1 × 2 + 1
2 = 2 × 1 + 0
That is 11 divisions, and the gcd is 1. Every quotient is 1 until the last. A quotient of 1 is the smallest a division can give, so the remainder shrinks as little as possible at each step. That is why no smaller pair can last as long: 233 and 144 are the smallest two numbers that need 11 divisions.
We show why gcd(Fₘ, Fₙ) is again a Fibonacci number in why gcd of Fibonacci numbers is a Fibonacci number.
How does the golden ratio prove the 5d bound?
Following Wikipedia's proof, suppose the algorithm on a > b takes N divisions.
Run the chain backwards. The last nonzero remainder is at least 1 = F₂, and the one before it is at least 2 = F₃, because the final quotient is at least 2. Each earlier number equals quotient × next + remainder, so it is at least the sum of the two after it. By induction, b ≥ F₍N+1₎.
Compare Fibonacci numbers with powers of the golden ratio φ = (1 + √5)/2 ≈ 1.618. Since φ² = φ + 1, induction gives F₍n+2₎ ≥ φⁿ.
Combine: b ≥ φ^(N−1). Take log base 10: log₁₀ b ≥ (N − 1) × log₁₀ φ, and log₁₀ φ ≈ 0.209, which is more than 1/5. So log₁₀ b ≥ (N − 1)/5.
If b has d digits, b < 10ᵈ, so log₁₀ b < d. Then N − 1 < 5d, and since N is a whole number, N ≤ 5d.
Check it on our example: N = 11, and φ¹⁰ ≈ 123, which is indeed no more than b = 144. The golden ratio turns up because its continued fraction is all 1s, the same "quotient always 1" pattern; see the golden ratio as a continued fraction.
Why is it called the first analysis of an algorithm's running time?
Wikipedia describes Lamé's proof as the beginning of computational complexity theory and the first practical application of the Fibonacci numbers (Wikipedia). The same article credits Reynaud (1811) with the first known analysis of Euclid's algorithm and Finck (1841) with an earlier, weaker bound that Lamé refined; Shallit's 1994 paper traces this history.
What made Lamé's bound stand out is its shape. The worst case grows with the number of digits, not with the size of the numbers. Two 100-digit numbers need at most 500 divisions. In today's terms, the number of steps grows only logarithmically with the numbers.
How can you use Lamé's theorem in practice?
A routine for any gcd question:
Count the digits d of the smaller number and write down the ceiling 5d before you start.
If your working runs past 5d lines, you have made an arithmetic slip.
If every quotient is 1 and the last is 2, the two numbers are g times consecutive Fibonacci numbers, where g is the gcd.
When a proof asks how fast the algorithm ends, use the backwards Fibonacci argument above.
For HCF, LCM and the other Class 10 real-number results, see our Real numbers Class 10 formulas guide. For the mathematics behind this, browse the Fermi Concept Library, where each concept has its own lesson. For practice, the Fermi Problem Library has a step-by-step solver that explains the reasoning, so you can check each division as you go.



