Created
April 22, 2012 04:10
-
-
Save feiskyer/2449988 to your computer and use it in GitHub Desktop.
isPrime
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
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