콜라츠
-
[알고리즘 문제] 프로그래머스 콜라츠 추측IT/알고리즘 2019. 5. 1. 11:40
간단한 알고리즘 문제를 가지고왔다. 수학자들은 어떻게 이런 공식들을 찾아내는지 정말 신기하다..... 소스코드↓↓↓ 1234567891011121314151617181920212223242526272829303132333435363738public class Collatz { public static void main(String[] args) { // TODO Auto-generated method stub Scanner scan = new Scanner(System.in); int n = scan.nextInt(); System.out.println(guess(n)); } //추측 함수 public static int guess(int n){ int result = n; int count = 0; /..