제곱수 구하기

han.user();·2023년 3월 31일
0

프로그래머스

목록 보기
7/87
post-thumbnail

double root = Math.sqrt(n);

class Solution {
    public int solution(int n) {
        int answer = 0;

        double root = Math.sqrt(n);
        if(root == (int)root) {
            return 1;
        } else {
            return 2;
        }
    }
}
profile
I'm still hungry.

0개의 댓글