3n+1猜想——模拟

时间:2023-03-09 10:02:16
3n+1猜想——模拟

package dxb.com;

import java.util.Scanner;

public class caixiang {

public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner sc = new Scanner (System.in);
int n= sc.nextInt();
int step=0;
while(n!=1){
if(n%2==0)
{
n=n/2;
}else {
n= (3*n+1)/2;
}
step++;
}
System.out.println(step);
sc.close();
}

}

不知道怎么出来个不能无法加载主类。。。。。有main函数呀