The 3n + 1 problem
Consider the following algorithm:
enter
print
if then STOP
if is odd then
else
GOTO 2
Given the input , the following sequence of numbers will be printed
It is conjectured that the algorithm above will terminate (when a is printed) for any integral input value. Despite the simplicity of the algorithm, it is unknown whether this conjecture is true. It has been verified, however, for all integers such that (and, in fact, for many more numbers than this.)
Given an input , it is possible to determine the number of numbers printed (including the ). For a given this is called the cycle-length of . In the example above, the cycle length of is .
For any two numbers and you are to determine the maximum cycle length over all numbers between and inclusive.
Input
The input will consist of a series of pairs of integers and , one pair of integers per line. All integers will be less than and greater than . You can assume that no operation overflows a -bit integer.
Output
For each pair of integers and you should output and in the same order in which they appeared in the input. Then print the maximum cycle length for integers between and including and . For each test case print three numbers on one line, separating them by one space.