나머지가 1이 되는 수 찾기

han.user();·2023년 4월 12일
0

프로그래머스

목록 보기
60/87
post-thumbnail

class Solution {
    public int solution(int n) {
        int answer = 0;

        for (int i = 1; i <= n; i++) {
            if (n % i == 1) {
                answer = i;
                break;
            }
        }
        return answer;
    }
}
profile
I'm still hungry.

0개의 댓글