update snippets 62-78
This commit is contained in:
committed by
Agamemnon Zorbas
parent
b5c4358995
commit
c829ed692e
@ -2,7 +2,7 @@
|
||||
|
||||
Checks if the provided integer is a prime number.
|
||||
|
||||
Check numbers from `2` to the square root of the given number.
|
||||
Check numbers from `2` to the square root of the given number.
|
||||
Return `false` if any of them divides the given number, else return `true`, unless the number is less than `2`.
|
||||
|
||||
```js
|
||||
@ -11,6 +11,9 @@ const isPrime = num => {
|
||||
for (var i = 2; i * i <= boundary; i++) if (num % i == 0) return false;
|
||||
return num >= 2;
|
||||
};
|
||||
// isPrime(11) -> true
|
||||
// isPrime(12) -> false
|
||||
```
|
||||
|
||||
```js
|
||||
isPrime(11) -> true
|
||||
isPrime(12) -> false
|
||||
```
|
||||
|
||||
Reference in New Issue
Block a user