본문 바로가기
Beakjoon&프로그래머스/Java

[백준/Java] 34437번 Number Reduction

by 현장 2025. 10. 15.

-Code

import java.util.Scanner;

public class BOJ34437 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int cnt = 0;

        while (N != 1) {
            if (N % 2 == 0) {
                N = N / 2;
            } else {
                N = N + (N * 2) + 1;
            }
            cnt++;
        }
        System.out.println(cnt);
    }
}