![프로그래머스 Lv.1 정수 제곱근 판별](https://img1.daumcdn.net/thumb/R750x0/?scode=mtistory2&fname=https%3A%2F%2Fblog.kakaocdn.net%2Fdn%2FLVS5z%2FbtsDqPtDzre%2F0XshCH8e9q5Hk3LwpfBuh0%2Fimg.png)
프로그래머스 Lv.1 정수 제곱근 판별개발자가 되기까지 (2023.08.16~2024.04.15)/[Algorithm] Programmers ver.Java2024. 1. 15. 14:53
Table of Contents
![](http://t1.daumcdn.net/tistory_admin/static/images/xBoxReplace_250.png)
<Solution>
class Solution {
public long solution(long n) {
long answer = -1;
long num = 0;
for(int i = 1; i<= n; i++) {
if(n / i == i && n % i == 0) {
answer = (long) Math.pow(i+1, 2);
break;
}
}
return answer;
}
}
728x90
@rlozlr :: 얼렁뚱땅 개발자
얼렁뚱땅 주니어 개발자
포스팅이 좋았다면 "좋아요❤️" 또는 "구독👍🏻" 해주세요!