Skip to content

Instantly share code, notes, and snippets.

@Mrshinezee
Created March 13, 2018 22:04
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Mrshinezee/ff941963c3949ca34033dff36a542127 to your computer and use it in GitHub Desktop.
Save Mrshinezee/ff941963c3949ca34033dff36a542127 to your computer and use it in GitHub Desktop.
showPrimeNunber created by Mrshinezee - https://repl.it/@Mrshinezee/showPrimeNunber
let n = 20;
function isPrime(n) {
for (let i = 2; i < n; i++) {
if ( n % i == 0) return false;
}
return true;
}
isPrime(n);
function showPrimes(n) {
for (let i = 2; i < n; i++) {
if (!isPrime(i)) continue;
alert(i); // a prime
}
}
showPrimes(n);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment