import java.util.Scanner;
public class Test {
public static void main(String[] args) throws InterruptedException {
Scanner sc = new Scanner(System.in);
System.out.print("请输入一个非0自然数:");
int n = sc.nextInt();
while(n != 1) {
Thread.sleep(500);
if(n % 2 == 0) {
n = n / 2;
} else {
n = n * 3 + 1;
}
System.out.println(n);
}
}
}
效果展示: