Last active
September 11, 2021 08:54
-
-
Save kyh196201/a3c713d0ce1d48975e5d21d910308f8a to your computer and use it in GitHub Desktop.
javascript check number is prime
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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