Skip to content

Commit fb1f9b8

Browse files
committed
Add 220502 정수 제곱근 판별.js
1 parent 4aaf8a2 commit fb1f9b8

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

level-1/정수-제곱근-판별.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,11 @@ function solution(n) {
2222
// 아니라면 -1 반환
2323
return -1;
2424
}
25+
26+
//정답 4 - jaewon1676
27+
function solution(n) {
28+
let s = parseInt(Math.sqrt(n)) // n의 제곱근을 확인
29+
if (s ** 2 === n) return ((s+1) ** 2)
30+
31+
return -1;
32+
}

0 commit comments

Comments
 (0)