题解 | #魔法数字变换#

魔法数字变换

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

全部评论

相关推荐

米哈游校招进主页喵:大佬 考虑我司不 考虑的话可以看我主页帖子
点赞 评论 收藏
分享
不愿透露姓名的神秘牛友
04-30 18:05
空屿编号:你把墨镜摘下来是不是这样😭
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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