题解 | #魔法数字变换#

魔法数字变换

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);
    }
}

全部评论

相关推荐

好羡慕走AI技术方向的人,实习薪资这么高😱 人比人气死人😭
勇敢的嘟教授在考古:芯片公司挣得多多的,钱给的还不如互联网
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务