Notice
Recent Posts
Recent Comments
Link
| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 1 | 2 | 3 | 4 | 5 | 6 | 7 |
| 8 | 9 | 10 | 11 | 12 | 13 | 14 |
| 15 | 16 | 17 | 18 | 19 | 20 | 21 |
| 22 | 23 | 24 | 25 | 26 | 27 | 28 |
Tags
- react
- type
- codewars
- TABLESPACE
- DB2
- manifest.json
- codewar
- Debug
- react hook
- IBM
- descendingOrder
- custom hook
- JDBC
- java api
- useEffect
- isSquare
- TypeScript
Archives
- Today
- Total
taesik
isPrime 본문
Define a function that takes one integer argument and returns logical value true or false depending on if the integer is a prime.
function isPrime(num) {
if (num < 2) return false;
const limit = Math.sqrt(num);
for (let i = 2; i <= limit; ++i) {
if (num % i === 0) {
return false;
}
}
return true;
}