题解 | #魔法数字变换#

魔法数字变换

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

全部评论

相关推荐

06-13 17:00
武汉大学 Java
6月了还有点击就送的offer吗😭,投麻了😢
叫我阿东就行:这个bg,也还没找到理想的工作吗?好难,好焦虑
点赞 评论 收藏
分享
06-04 09:27
门头沟学院 Java
点赞 评论 收藏
分享
爱吃肉的伊登在写日记:好棒,27届简历能做成这个样子,但是第一个项目感觉cover住难度还是不小的,特别是二面的时候肯定要对分布式系统设计这一块儿有高出正常面试者的水平才行
点赞 评论 收藏
分享
曲霜晨:娱乐至上的年代
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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