Euclid's worst-case step count

The Euclidean algorithm computes gcd⁡(a,b)=gcd⁡(b, a mod b)\gcd(a,b) = \gcd(b,\, a \bmod b), repeating until the second argument is 00. Count the number of  mod \bmod (remainder) operations performed for gcd⁡(34,21)\gcd(34, 21).

Show hints (2)+
  1. 3434 and 2121 are consecutive Fibonacci numbers - the worst case.
  2. Trace gcd⁡(b,a mod b)\gcd(b, a\bmod b) until the remainder is 00; count the  mod \bmods.

Answer

Reveal answer →

7

Create a free account to see the full worked solution and track your progress.

Interview format: Prop Trading, Systematic & Data-Driven Trading

Related questions