题解 | #魔法数字变换#
魔法数字变换
http://www.nowcoder.com/practice/db41a6ce80a646aa9a5eb6252ac2df76
import java.util.Scanner; public class Main{ public static void main(String[]args){ Scanner sc = new Scanner(System.in); int n= sc.nextInt(); int sum=0; while(n!=1) { if(n%2==0) { n=n/2; sum++; }else{ n=3*n+1; sum++; } } System.out.println(sum); } }