프로그래머스 제곱수 판별하기 자바스크립트

버건디·2023년 3월 9일
0

프로그래머스

목록 보기
12/66

문제 링크

- 내 풀이

function solution(n) {
  const num = Math.sqrt(n);

  if (Math.floor(num) === num) {
    return 1;
  } else {
    return 2;
  }
}

- 다른 사람 풀이

function solution(n) {
  return Number.isInteger(Math.sqrt(n)) ? 1 : 2;
}
profile
https://brgndy.me/ 로 옮기는 중입니다 :)

0개의 댓글

관련 채용 정보