Skip to content

Instantly share code, notes, and snippets.

@kyh196201
Last active September 11, 2021 08:54
Show Gist options
  • Save kyh196201/a3c713d0ce1d48975e5d21d910308f8a to your computer and use it in GitHub Desktop.
Save kyh196201/a3c713d0ce1d48975e5d21d910308f8a to your computer and use it in GitHub Desktop.
javascript check number is prime
function isPrime(num) {
for(let i = 2, s = Math.sqrt(num); i <= s; i++) {
if(num % i === 0) return false;
}
return num > 1;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment