Skip to content

Commit c389a2a

Browse files
committed
solve: 나머지가 1이 되는 수 찾기 문제풀이
1 parent 17e756d commit c389a2a

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
function solution(n) {
2+
for (let x = 2; x < n; x++) {
3+
if (n % x === 1) {
4+
return x;
5+
}
6+
}
7+
}
8+
9+
// 다른 풀이
10+
// function solution(n, x = 1) {
11+
// while (x++) {
12+
// if (n % x === 1) {
13+
// return x;
14+
// }
15+
// }
16+
// }

0 commit comments

Comments
 (0)