728x90
반응형
https://programmers.co.kr/learn/courses/30/lessons/87389
using System;
public class Solution {
public int solution(int n) {
int answer = 0;
for (int i = 1; ++i < n - 1;)
if (n % i == 1)
{
answer = i;
break;
}
if (answer == 0) answer = n - 1;
return answer;
}
}
반응형
'프로그래머스_C# > Level_1' 카테고리의 다른 글
[프로그래머스 C#] 신고 결과 받기 (0) | 2022.04.13 |
---|---|
[프로그래머스 C#] 8주차_최소직사각형 (0) | 2021.10.21 |
[프로그래머스 C#] 없는 숫자 더하기 (0) | 2021.10.19 |
[프로그래머스 C#] 6주차_복서 정렬하기 (0) | 2021.10.18 |
[프로그래머스 C#] Level 1 Tips (0) | 2021.09.11 |