import java.util.Scanner;
public class Main{
public static int c(int n){
int i=0;
while(n!=1){
if(n%2==0) n=n/2;
else n=3*n+1;
i++;
}
return i+1;
}
public static void main(String[] argc) {
Scanner cin=new Scanner(System.in);
int max=0;
while(cin.hasNext()){
max=0;
int a=cin.nextInt();
int b=cin.nextInt();
for(int i=a;i<=b;i++){
if(c(i)>max) max=c(i);
}
System.out.printf("%d %d %d\n",a,b,max);
}
}
}
The 3n + 1 problem tzc
最新推荐文章于 2024-06-30 21:28:18 发布