1 #include <cstdio> 2 3 int main() 4 { 5 long int F, S, I, Count, Value, Max, J; 6 while(scanf("%ld %ld", &F, &S) && F) 7 { 8 if(F > S) { F ^= S; S ^= F; F ^= S; } 9 Max = 0; 10 for(I = F; I <= S; I++) 11 { 12 Count = 0; 13 J = I; 14 do{ 15 if(J % 2) (J *= 3) ++; 16 else J /= 2; 17 Count ++; 18 }while(J != 1); 19 if(Count > Max) { Value = I; Max = Count; } 20 } 21 printf("Between %ld and %ld, %ld generates the longest sequence of %ld values. ",F, S, Value, Max); 22 } 23 return 0; 24 }