Created
February 1, 2016 17:15
-
-
Save giannispan/9ba54ca6f57d849ebf80 to your computer and use it in GitHub Desktop.
Is a number 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) { | |
var start = 2; | |
while (start <= Math.sqrt(num)) { | |
if (num % start++ < 1) return false; | |
} | |
return num > 1; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment