Skip to content

Instantly share code, notes, and snippets.

@kenessajr
Created June 12, 2018 09:59
Show Gist options
  • Save kenessajr/a8ded99030685e31e205e07288b30cc7 to your computer and use it in GitHub Desktop.
Save kenessajr/a8ded99030685e31e205e07288b30cc7 to your computer and use it in GitHub Desktop.
Return all prime number in a given range
""" function to return if it's a prime number """
def is_prime(n):
for i in range(3, n):
if n % i == 0:
return False
return True
n_range = int(input('Enter your range '))
for n in range(2, n_range):
if is_prime(n):
print n
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment