Skip to content

Instantly share code, notes, and snippets.

@GrAndSE
Created September 21, 2011 14:08
Show Gist options
  • Select an option

  • Save GrAndSE/1232121 to your computer and use it in GitHub Desktop.

Select an option

Save GrAndSE/1232121 to your computer and use it in GitHub Desktop.
Prime numbers searching using Python
def primes(num):
def is_prime(n):
limit = int(n**0.5) + 1
for i in range(2, limit):
if n % i == 0:
return False
return True
return [n for n in range(2, num) if is_prime(n)]
print primes(1000000)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment