-
프로그래머스 - 나머지가 1이 되는 수 찾기 [자바]Algorithms/- 프로그래머스 2022. 1. 31. 03:10
- 문제 링크 : 나머지가 1이 되는 수 찾기
정답
class Solution { public int solution(int n) { int answer = 2; while(n % answer != 1){ answer++; } return answer; } }
분석
- 단순 반복문
반응형
class Solution {
public int solution(int n) {
int answer = 2;
while(n % answer != 1){
answer++;
}
return answer;
}
}