Skip to content

Instantly share code, notes, and snippets.

@lienista
Last active August 28, 2018 05:38
Show Gist options
  • Select an option

  • Save lienista/6d2a725c3d3ac40145db5257e8fbfdc7 to your computer and use it in GitHub Desktop.

Select an option

Save lienista/6d2a725c3d3ac40145db5257e8fbfdc7 to your computer and use it in GitHub Desktop.
const isPrime = (n) => {
if(n<3) return false;
if(n%2===0) return false;
if(n%3===0) return false;
let limit = Math.sqrt(n);
for(let i=5; i<=limit; i+=6){
if(num%i ===0) return false;
if(num%(i+2) ===0) return false;
}
return true;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment