
์ด๋ค ์์ฐ์๋ฅผ ์ ๊ณฑํ์ ๋ ๋์ค๋ ์ ์๋ฅผ ์ ๊ณฑ์๋ผ๊ณ  ํฉ๋๋ค. ์ ์ n์ด ๋งค๊ฐ๋ณ์๋ก ์ฃผ์ด์ง ๋, n์ด ์ ๊ณฑ์๋ผ๋ฉด 1์ ์๋๋ผ๋ฉด 2๋ฅผ returnํ๋๋ก solution ํจ์๋ฅผ ์์ฑํด์ฃผ์ธ์.
n โค 1,000,000| n | result | 
|---|---|
| 144 | 1 | 
| 976 | 2 | 
์ ์ถ๋ ฅ ์ #1
์ ์ถ๋ ฅ ์ #2
const solution = n => Number.isInteger(Math.sqrt(n)) ? 1 : 2