Created
September 13, 2017 02:05
-
-
Save platedodev/dc6610698413e43451fd5d8eb8b89389 to your computer and use it in GitHub Desktop.
Kata - Twin 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 isTwinPrime(n){ | |
return (isPrime(n) && (isPrime(n-2) || isPrime(n+2))); | |
} | |
function isPrime(n) { | |
for (var i = 2; i < n; i++) if (n % i == 0) return false; | |
return n >= 2; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment