代码如下:
import java.util.Scanner; public class Main { public static void main(String[] args) { // TODO Auto-generated method stub Scanner input = new Scanner(System.in); int n = input.nextInt(); int count = 0; while(n!=1){ count++; if(n%2==0){ n=n>>1; }else{ n=(3*n+1)>>1; } } System.out.println(count); } }