728x90


class Solution {
    public int solution(int n) {
        int answer = 0;
        for(int i = 1; i<=1000000; i++){
            if(n%i==1){
                answer = i;
                break;
            }
        }
        return answer;
    }
}
728x90
반응형
복사했습니다!