ECOO AT GRAMERCY 1999

3N + 1

INPUT FILE: triple.in
OUTPUT FILE: triple.out

Consider the following procedure:

Procedure ThreeNPlusOne(var N: longint);
begin
   while N<>1 do
   begin
      if N mod 2 = 0 then
         N := N div 2
      else
         N := 3*N + 1;
   end;
end;
Although it looks deceptively simple, it has to this day not been proven whether this code halts (eventually exists the while loop) for every input N. Most computer scientists conjecture that it does, However, for some inputs the algorithm takes a surprisingly large number of iterations to quit. Given two integer numbers a and b, find the number N in the range a..b which takes the maximum number of iterations to exit this loop. This program should run within 10 seconds on a Pentium 166MHz.

INPUT
The numbers a and b, separated by a space.

OUTPUT
Output the maximum number of iterations the procedures takes as N ranges over the values a..b and the value of N which gives this maximum.

Sample Input File

1 8

Output for Sample Input

Maximum iterations = 16 for N = 7
Downloader failed! Response object 006~ASP 0159~Buffering Off~Buffering must be on.