Travis build: 69
This commit is contained in:
@ -1386,10 +1386,9 @@ Returns `false` if the provided number has positive divisors other than 1 and it
|
||||
const isPrime = num => {
|
||||
for (var i = 2; i * i <= num; i++) if (num % i == 0) return false;
|
||||
return num >= 2;
|
||||
}
|
||||
};
|
||||
// isPrime(11) -> true
|
||||
// isPrime(12) -> false
|
||||
// isPrime(1) -> false
|
||||
```
|
||||
|
||||
[⬆ back to top](#table-of-contents)
|
||||
@ -2184,3 +2183,4 @@ const validateNumber = n => !isNaN(parseFloat(n)) && isFinite(n) && Number(n) ==
|
||||
## Credits
|
||||
|
||||
*Icons made by [Smashicons](https://www.flaticon.com/authors/smashicons) from [www.flaticon.com](https://www.flaticon.com/) is licensed by [CC 3.0 BY](http://creativecommons.org/licenses/by/3.0/).*
|
||||
|
||||
|
||||
@ -868,12 +868,11 @@ Returns <code>true</code> if the number is even, <code>false</code> if the numbe
|
||||
<p>Checks if the provided integer is a prime number.</p>
|
||||
<p>Returns <code>false</code> if the provided number has positive divisors other than 1 and itself or if the number itself is less than 2.</p>
|
||||
<pre><code class="language-js">const isPrime = num => {
|
||||
for (var i = 2; i < num; i++) if (num % i == 0) return false;
|
||||
for (var i = 2; i * i <= num; i++) if (num % i == 0) return false;
|
||||
return num >= 2;
|
||||
}
|
||||
};
|
||||
// isPrime(11) -> true
|
||||
// isPrime(12) -> false
|
||||
// isPrime(1) -> false
|
||||
</code></pre>
|
||||
</div></div><br/><div class="card fluid"><div class="section double-padded"><h3 id="lcm">lcm</h3></div><div class="section double-padded">
|
||||
<p>Returns the least common multiple of two numbers.</p>
|
||||
|
||||
Reference in New Issue
Block a user