Notice
Recent Posts
Recent Comments
Link
«   2025/07   »
1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30 31
Tags
more
Archives
Today
Total
관리 메뉴

코딩응급실

프로그래머스: 나머지가 1이 되는 수 찾기 본문

Java

프로그래머스: 나머지가 1이 되는 수 찾기

Daeryuk Kim 2024. 1. 20. 16:28
class Solution {
    public int solution(int n) {
        int answer = 1;

        while(true) {
            if (n%answer==1) break;
            answer++;
        }

        return answer;
    }
    
    public static void main(String[] args) {
        
        int n = 12;
        
        Solution sol = new Solution();
        int result = sol.solution(n);
     
        System.out.println(result); 
        
    }
}