题解 | #魔法数字变换#
魔法数字变换
https://ac.nowcoder.com/acm/problem/22163
import java.util.Scanner;
public class Main{
public static void main(String[] args){
Scanner scan = new Scanner(System.in);
int n = scan.nextInt();
int count = 0;
while(true){
if(n == 1){
break;
}else {
if(n % 2 == 0){
n /= 2;
count++;
}else{
n = 3 * n + 1;
count++;
}
}
}
System.out.println(count);
}
}