본문 바로가기
Algorithm/프로그래머스

[Algorithm / Programmers] 정수 제곱근 판별

by newtownboy 2024. 4. 1.


[Version]
⦁ 2024.04.01 / [Algorithm / Programmers] 정수 제곱근 판별

 

class Solution {
    public long solution(long n) {
        if(Math.pow(Math.sqrt(n) + 1, 2) % 1 == 0) {
            return (long) Math.pow(Math.sqrt(n) + 1, 2);
        }
        return -1;
    }
}