How to check a number is prime & How to find prime

Run Settings
LanguageJavaScript
Language Version
Run Command
function isPrime(n) { if(n < 2) return false; for(let i = 2; i < n; i++){ if(n%i==0){ return false; } } return true; } console.log(isPrime(9)); console.log(isPrime(10)); console.log(isPrime(11)); console.log(isPrime(4)); console.log(isPrime(5)); console.log(isPrime(6)); console.log(isPrime(7)); console.log(isPrime(8)); // function showPrimes(max) { // for(let i = 2; i <= max; i++){ // if(isPrime(i)){ // console.log(i) // } // } // } // showPrimes(100);
Editor Settings
Theme
Key bindings
Full width
Lines