Skip to content

Instantly share code, notes, and snippets.

@akkerman
Created August 9, 2013 22:36
Show Gist options
  • Save akkerman/6197876 to your computer and use it in GitHub Desktop.
Save akkerman/6197876 to your computer and use it in GitHub Desktop.
import math
def is_prime(n):
if (n == 2):
return True
if (n == 1 or n % 2 == 0):
return False
square = int(math.ceil(math.sqrt(abs(n)))) + 1
i = 3
while i <= square:
if (n % i == 0):
return False
i+=2
return True
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment