Skip to content

Instantly share code, notes, and snippets.

@feiskyer
Created April 22, 2012 04:10
Show Gist options
  • Save feiskyer/2449988 to your computer and use it in GitHub Desktop.
Save feiskyer/2449988 to your computer and use it in GitHub Desktop.
isPrime
def isPrime(n):
n=abs(n)
if n<=1:
return False
if n==2:
return True
if not n&1:
return False
i=3
while i*i<=n:
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