Last active
April 15, 2016 21:31
-
-
Save RyanBreaker/829712d9a980a19e9f6f83dcbe1d3204 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
func isPrime(n: Int) -> Bool { | |
if n % 2 == 0 { | |
return false | |
} | |
for i in 3.stride(to: (n+1)/2, by: 2) { | |
if n % i == 0 { | |
return false | |
} | |
} | |
return true | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment