Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit dba2c36

Browse files
Add 정수-제곱근-판별.js
1 parent 359690c commit dba2c36

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,14 @@ function solution(n) {
1414
let x = Math.sqrt(n);
1515
// x가 정수이면 x+1의 제곱 반환, x가 정수가 아니면 -1 반환
1616
return Number.isInteger(x) ? Math.pow(x + 1, 2) : -1;
17+
}
18+
19+
//정답 3 - prove-ability
20+
function solution(n) {
21+
// n의 제곱근을 x 초기화
22+
const x = Math.sqrt(n);
23+
// 양의 정수라면 x + 1 제곱 반환
24+
if(Number.isInteger(x)) return Math.pow(x + 1, 2)
25+
// 아니라면 -1 반환
26+
return -1;
1727
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /