Given $a$, where $a$ and $b$ are positive integers with $a > b$, how can I find the values for $b$ which give the maximum number of steps for the Euclidean algorithm $\gcd(a,b)$?
For example, where $a = 1000, b = 703$ and $b = 633$ both give the maximum number of steps:
$$(1000,703) → (703,297) → (297,109) → (109,79) → (79,30) → (30,19) → (19,11) → (11,8) → (8,3) → (3,2) → (2,1)$$
$$(1000,633) → (633,367) → (367,266) → (266,101) → (101,64) → (64,37) → (37,27) → (27,10) → (10,7) → (7,3) → (3,1)$$
If $a$ is the Fibonacci number $F_n$, then $b= F_{n-1}$ gives the maximum number of steps, but I'm looking for a method that works for any $a$.
Thanks.
Update: C code to list all b which take max steps
I've been using the following code to iterate through all possible b and display those which take the max number of steps. However, I was hoping there might be some way to calculate solutions or narrow the range.
#include <stdio.h>
/* count number of steps for Euclidean algorithm */
int gcd_steps(int a, int b)
{
return !a ? 0 : 1 + gcd_steps( b % a, a );
}
/* for each A (1-50), display the maximum number of steps for the
Euclidean algorithm and list all B which take the max steps */
void main()
{
int a, b, max_steps;
for ( a=1; a<=50; a++ )
{
max_steps = 0;
for ( b=1; b<a; b++ )
if ( gcd_steps( b,a ) > max_steps )
max_steps = gcd_steps( b, a );
printf( "%i [%i] ",a , max_steps );
for ( b=1; b<a; b++ )
if ( gcd_steps( b, a ) == max_steps )
printf( "%i,",b );
printf( "\n" );
}
}