1.

/**
* Angewandte Mathematik, SS09, IFB 2C
* ACM Problem #371 (Ackermann)
* Link: http://icpcres.ecs.baylor.edu/onlinejudge/external/3/371.pdf
*
* @author Christian Posselt
* @author Jonathan Schubert
* @version 1.0, 03/25/2009
*
* Status : Accepted
* Runtime: 1.780
*/

import java.util.Scanner;


public class Ackermann371
{
public static void main(String[] args)
{
Scanner scanner;
int start,end;

scanner = new Scanner(System.in);
//read user input
while(scanner.hasNext())
{
start = scanner.nextInt();
end = scanner.nextInt();
//end of user input
if(end == 0 && start == 0)
break;
Ackermann371.Output(start,end);
}
}

public static void Output(int start, int end)
{
//twist interval
if(start > end)
{
int temp = end;
end = start;
start = temp;
}
//Set standard values for one as special number
int i;
int max = 3;
int maxvalue = 1;
//run through given interval
for(i = start; i <= end; i++)
{
int count = 0;

int testdigit = i;
do
{
//calculate the ackermann
if(testdigit%2 == 0)
testdigit /= 2;
else
testdigit = testdigit*3+1;
count ++;
}while(testdigit > 1);

//find max serias length
if(max < count)
{
max = count;
maxvalue = i;
}
}
//Print information to screen
System.out.println("Between "+start+" and "+end+", "+maxvalue+" generates the longest sequence of "+max+" values.");
}
}