using System;
public class Solution {
public int solution(int n) {
int answer = 0;
for (int i = 2; i < n; i++) {
if(n%i == 1) {
answer = i;
break;
}
}
return answer;
}
}
'프로그래머스 > Lv.1' 카테고리의 다른 글
[프로그래머스 C#] 정수 내림차순으로 배치하기 (0) | 2023.08.28 |
---|---|
[프로그래머스 C#] 약수의 합 (0) | 2023.08.28 |
[프로그래머스 C#] 직사각형 별찍기 (0) | 2023.08.23 |
[프로그래머스 C#] x만큼 간격이 있는 n개의 숫자 (0) | 2023.08.23 |
[프로그래머스 C#] 자연수 뒤집어 배열로 만들기 (0) | 2023.08.22 |