0

Let $1\leq y\leq x\leq 2020$ be natural numbers.

Find an upper bound for the number of iterations over the Euclidean algorithm on $(x,y)$.

I don't have any idea how to solve it. Is it possible to explain how to find the upper bound? I can run a Python code but I would like to understand the math.

EDIT: Actually tried to run the code but it didn't give me much information.

vesii
  • 2,049
  • Well, certainly $4000$ is an upper bound, since the remainder decreases at each step. Much tighter bounds are possible. – paw88789 May 17 '20 at 13:39
  • Hint: If $a,b$ take $n$ iterations, with $a\lt b$, then $b,a+b$ will take $n+1$ iterations. – Barry Cipra May 18 '20 at 08:40
  • Possible duplicate of https://math.stackexchange.com/questions/2477328/why-are-fibonacci-numbers-bad-for-euclids-algorithm-and-how-to-derive-this-uppe and see also https://math.stackexchange.com/questions/1483118/proving-the-number-of-iterations-in-the-euclidean-algorithm and also https://math.stackexchange.com/questions/1957075/show-that-the-euclidean-algorithm-terminates-in-less-than-seven-times-the-number – Gerry Myerson May 18 '20 at 08:55
  • @GerryMyerson tried to look at them but still didn't solved it. – vesii May 19 '20 at 06:51
  • 1
    The answer by Winter in my first link proves "in the worst case for an input pair with elements of minimum size $s$, the Euclidean algorithm terminates after about $\log_{\phi}s$ steps." Isn't that exactly what you want? In the second link, it's shown that if $\min(m, n)\leq2^k$ for some natural number $k$, then the Euclidean algorithm needs at most $2k$ iterations to find the $\gcd(m,n)$. Isn't that what you want? Also, almost every introductory Number Theory text will have a similar result, with proof. Can you get to a university library? – Gerry Myerson May 19 '20 at 13:17
  • I'm sorry, but I don't understand what question you have that isn't answered in those links. – Gerry Myerson May 21 '20 at 11:54
  • Are you still here, vesii? – Gerry Myerson May 24 '20 at 23:23

1 Answers1

0

The highest number of iterations alway occurs when $x(x,y)$ are consecutive Fibonacci numbers so the max number of iterations is the "ordinal" number of the lesser Fibonacci number that is greater than or equal to the lesser of the two inputs. Note that entering the greater number 2nd will result in one more iteration.

Here is a sample run comparing iterations for all pairs up to $100$ and displaying only the first time an iteration count is greater than the previous highest count.

 enter limit? 5000
 iterations( 1 )    GCD( 2 , 1 ) = 1 
 iterations( 2 )    GCD( 3 , 2 ) = 1 
 iterations( 3 )    GCD( 5 , 3 ) = 1 
 iterations( 4 )    GCD( 8 , 5 ) = 1 
 iterations( 5 )    GCD( 13 , 8 ) = 1 
 iterations( 6 )    GCD( 21 , 13 ) = 1 
 iterations( 7 )    GCD( 34 , 21 ) = 1 
 iterations( 8 )    GCD( 55 , 34 ) = 1 
 iterations( 9 )    GCD( 89 , 55 ) = 1 
 iterations( 10 )   GCD( 144 , 89 ) = 1 
 iterations( 11 )   GCD( 233 , 144 ) = 1 
 iterations( 12 )   GCD( 377 , 233 ) = 1 
 iterations( 13 )   GCD( 610 , 377 ) = 1 
 iterations( 14 )   GCD( 987 , 610 ) = 1 
 iterations( 15 )   GCD( 1597 , 987 ) = 1 
 iterations( 16 )   GCD( 2584 , 1597 ) = 1 
 iterations( 17 )   GCD( 4181 , 2584 ) = 1 
poetasis
  • 6,795