[Java] 3n+1 문제 : The Collatz problem
·
💡 CodingTest/UVa
[Java] 3n+1 문제 : The Collatz problem 문제 설명 내 코드 import java.io.*; import java.util.*; class Main { public static void main(String[] args) throws Exception { Scanner scanner = new Scanner(System.in); while(scanner.hasNextLine()){ int n= scanner.nextInt(); int m= scanner.nextInt(); int max=0; for(int i=n; imax) max=count; } System.out.println(n +" "+ m +" "+max); } } } 🔑 Key Point 🔑 max 변수 잡아주는 것
슬라임 통통
'The Collatz problem' 태그의 글 목록