Skip to content

Instantly share code, notes, and snippets.

@Rushi98
Created May 10, 2016 15:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Rushi98/01841d7f56febb773568f6d491e2a596 to your computer and use it in GitHub Desktop.
Save Rushi98/01841d7f56febb773568f6d491e2a596 to your computer and use it in GitHub Desktop.
def isprime(n):
if n<=1:
return False
elif n<4:
return True
elif n%2==0 or n%3==0:
return False
elif n<9:
return True
elif n%5==0:
return False
else:
k=5
while k<((n**0.5)//1+1):
if n%k==0 or n%(k+2)==0:
return False
k=k+6
return True
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment