题解 | #魔法数字变换#
魔法数字变换
https://www.nowcoder.com/practice/db41a6ce80a646aa9a5eb6252ac2df76
public class Program { public static void Main() { int inPut = int.Parse(System.Console.ReadLine()); int index = 0; while (inPut != 1) { if (inPut % 2 == 0) inPut /= 2; else if (inPut % 2 != 0) inPut = (inPut * 3) + 1; index++; } System.Console.WriteLine(index); } }