Skip to content

Instantly share code, notes, and snippets.

@codeadict
Created September 29, 2015 17:29
Show Gist options
  • Save codeadict/050ec5a28a4839f3e5fe to your computer and use it in GitHub Desktop.
Save codeadict/050ec5a28a4839f3e5fe to your computer and use it in GitHub Desktop.
Generates a list of prime numbers from 2 to N. Done for a friend homework of MIT edx.
def primesList(N):
"""
Generates a list of prime numbers from 2 to N.
N: an integer
"""
return [a for a in range(2, N) if not [b for b in range(2,a) if not a%b]]
def __main__():
print primesList(100)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment