class Solution {
public double solution(double n) {
double answer = 0;
double sqrtNumber = Math.sqrt(n);
if(n%sqrtNumber == 0){
answer= Math.pow(sqrtNumber+1, 2);
}else{
answer = -1;
}
return answer;
}
}
'공부기록 > 프로그래머스' 카테고리의 다른 글
[프로그래머스] 콜라츠 추측 (0) | 2023.08.29 |
---|---|
[프로그래머스] 정수 내림차순 배치하기 (0) | 2023.08.29 |
[프로그래머스] 음양 더하기 (0) | 2023.08.25 |
[프로그래머스] x만큼 간격이 있는 n개의 숫자 (0) | 2023.08.25 |
[프로그래머스] 피보나치 수 (0) | 2023.08.24 |