https://school.programmers.co.kr/learn/courses/30/lessons/120909
프로그래머스
코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요.
programmers.co.kr
function solution(n) {
var answer = 0;
if (Number.isInteger(Math.sqrt(n))) {answer=1;}
else {answer=2;}
return answer;
}
+)230511
const solution = (n) => {
return (Number.isInteger(Math.sqrt(n)) ? answer = 1 : answer = 2);
}
230525 python
def solution(n):
answer = 2
if n ** 0.5 == n // n ** 0.5:
answer = 1
return answer
이야 나 천재아닌가
C++
#include <cmath>
using namespace std;
int solution(int n) {
int x = sqrt(n);
return (n%x==0) ? 1 : 2;
}
'코딩테스트 > LV. 0' 카테고리의 다른 글
LV. 0 :: 배열 회전시키기 (0) | 2023.01.22 |
---|---|
LV. 0 :: 숨어있는 숫자의 덧셈 1 (0) | 2023.01.22 |
LV. 0 :: 숫자 찾기 (0) | 2023.01.21 |
LV. 0 :: 모음 제거 (0) | 2023.01.21 |
LV. 0 :: 편지 (0) | 2023.01.21 |
댓글