Skip to content

Instantly share code, notes, and snippets.

@ignaciovillela
Last active March 27, 2017 01:02
Show Gist options
  • Save ignaciovillela/56102a669cfb75293c3966b786e95a26 to your computer and use it in GitHub Desktop.
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)
# 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