문제
코드
class Solution {
public int solution(int n) {
return (Math.sqrt(n) % 1 == 0) ? 1 : 2;
}
}
💘 제곱근 구하기
- Math.sqrt() 메소드는 입력값과 출력값은 모두 double형
'코딩테스트' 카테고리의 다른 글
[프로그래머스/자바] 대소문자 바꿔서 출력하기 (0) | 2023.05.29 |
---|---|
[프로그래머스/자바] 짝수는 싫어요 (0) | 2023.05.27 |