Skip to content

Baekjoon 14920

1. Problem

문제 확인하기

2. Solution (C++17, memory: 2020KB, time: 0ms)

#include <iostream>
using namespace std;

int main() {
    int n;
    cin >> n;

    int i = 1;
    while (n != 1) {
        if (n % 2 != 0) {
            n = 3 * n + 1;
        } else {
            n = n / 2;
        }
        i += 1;
    }

    cout << i;
    return 0;
}