File tree Expand file tree Collapse file tree
프로그래머스/0/120909. 제곱수 판별하기 Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ # [ level 0] 제곱수 판별하기 - 120909
2+
3+ [ 문제 링크] ( https://school.programmers.co.kr/learn/courses/30/lessons/120909 )
4+
5+ ### 성능 요약
6+
7+ 메모리: 33.3 MB, 시간: 0.03 ms
8+
9+ ### 구분
10+
11+ 코딩테스트 연습 > 코딩테스트 입문
12+
13+ ### 채점결과
14+
15+ 정확성: 100.0<br />합계: 100.0 / 100.0
16+
17+ ### 제출 일자
18+
19+ 2025년 05월 06일 20:30:05
20+
21+ ### 문제 설명
22+
23+ <p >어떤 자연수를 제곱했을 때 나오는 정수를 제곱수라고 합니다. 정수 <code >n</code >이 매개변수로 주어질 때, <code >n</code >이 제곱수라면 1을 아니라면 2를 return하도록 solution 함수를 완성해주세요.</p >
24+
25+ <hr >
26+
27+ <h5 >제한사항</h5 >
28+
29+ <ul >
30+ <li >1 ≤ <code >n</code > ≤ 1,000,000</li >
31+ </ul >
32+
33+ <hr >
34+
35+ <h5 >입출력 예</h5 >
36+ <table class =" table " >
37+ <thead><tr>
38+ <th >n</th >
39+ <th >result</th >
40+ </tr >
41+ </thead >
42+ <tbody><tr>
43+ <td >144</td >
44+ <td >1</td >
45+ </tr >
46+ <tr >
47+ <td >976</td >
48+ <td >2</td >
49+ </tr >
50+ </tbody >
51+ </table>
52+ <hr >
53+
54+ <h5 >입출력 예 설명</h5 >
55+
56+ <p >입출력 예 #1</p >
57+
58+ <ul >
59+ <li >144는 12의 제곱이므로 제곱수입니다. 따라서 1을 return합니다.</li >
60+ </ul >
61+
62+ <p >입출력 예 #2</p >
63+
64+ <ul >
65+ <li >976은 제곱수가 아닙니다. 따라서 2를 return합니다.</li >
66+ </ul >
67+
68+
69+ > 출처: 프로그래머스 코딩 테스트 연습, https://school.programmers.co.kr/learn/challenges
Original file line number Diff line number Diff line change 1+ function solution ( n ) {
2+ var answer = Number . isInteger ( Math . sqrt ( n ) ) ? 1 : 2 ;
3+ return answer ;
4+ }
You can’t perform that action at this time.
0 commit comments