Skip to content

Instantly share code, notes, and snippets.

@esron
Created November 24, 2019 15:21
Show Gist options
  • Select an option

  • Save esron/d70384dd61c337b81ad5a362b52d0da5 to your computer and use it in GitHub Desktop.

Select an option

Save esron/d70384dd61c337b81ad5a362b52d0da5 to your computer and use it in GitHub Desktop.
Determ if a positive integer is prime
def isPrime(n):
if n <= 3:
return n > 1
if not n % 2 or not n % 3:
return False
i = 5
while(i * i <= n):
if not n % i or not n % (i + 2):
return False
i += 6
return True
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment