Last active
March 27, 2017 01:02
-
-
Save ignaciovillela/56102a669cfb75293c3966b786e95a26 to your computer and use it in GitHub Desktop.
List of prime numbers from 1 to N in a line in Python. (Lista de números primos de 1 a N en una linea en Python)
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
# List of prime numbers from 1 to N in a line in Python | |
# Lista de números primos de 1 a N en una linea en Python | |
def prime_numbers(n): | |
return ([2] + [x for x in range(3, n+1, 2) if not [y for y in range(3, int(x**0.5)+1, 2) if (float(x) / y).is_integer()]]) if n >= 2 else [] | |
print(prime_numbers(100)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment