기록

[Level1] 정수 제곱근 판별 본문

Algorithm/Programmers

[Level1] 정수 제곱근 판별

dev.jung 2021. 7. 14. 15:37

문제

내 풀이

Math 내장함수를 활용하여 푼다.

 

 

const solution = (n) => Number.isInteger(Math.sqrt(n)) ? Math.pow(Math.sqrt(n) + 1, 2) : -1

출처: https://developer.mozilla.org/ko/docs/Web/JavaScript/Reference/Global_Objects/Math

 

Math - JavaScript | MDN

Math는 수학적인 상수와 함수를 위한 속성과 메서드를 가진 내장 객체입니다.

developer.mozilla.org

 

반응형
Comments