Skip to content

Instantly share code, notes, and snippets.

@RyanBreaker
Last active April 15, 2016 21:31
Show Gist options
  • Save RyanBreaker/829712d9a980a19e9f6f83dcbe1d3204 to your computer and use it in GitHub Desktop.
Save RyanBreaker/829712d9a980a19e9f6f83dcbe1d3204 to your computer and use it in GitHub Desktop.
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