javascript find a prime number
// This seems to be the most common and comprehensive means
// of implementing a 'is a number a prime function' in javascript
// if you would like t0 learn more complex , but efficient algorithms.
// Visit the link below
// https://stackoverflow.com/questions/11966520/how-to-find-prime-numbers-between-0-100
function isPrime(num) {
if(num < 2) return false;
for (let k = 2; k < num; k++){
if( num % k == 0){
return false;
}
}
return true;
}function isPrime(num) {
for (let i = 2; i * i <= num; i++)
if (num % i === 0)
return false;
return num > 1;
}
Also in JavaScript:
- replace all occurrences of a string in javascript
- js check if variable is string
- chrome extension how to save data to an alternative file
- replace js
- shadown reAct native
- javascript flat object
- export aab react native
- swap elements in array javascript
- localForage
- legend on click use default chartjs
- js ajax
- mongoose find and update prop
- load_jsonl love jsonl
- d3 disable context menu
- range javascript
- jason rpc reactjs
- split a message
- javascript get random integer in given range
- flatten an array in javascript
- javascript call() & apply() vs bind()?
- how to put firebase config in a sperate file react native
- get count of class which is visible element
- how to play sound on load js
- unterminated character class react native