Skip to content

Instantly share code, notes, and snippets.

@dongho-jung
Created July 28, 2017 10:33
Show Gist options
  • Save dongho-jung/0e44be0c7b8102a0ff63c890ddc5d8c9 to your computer and use it in GitHub Desktop.
Save dongho-jung/0e44be0c7b8102a0ff63c890ddc5d8c9 to your computer and use it in GitHub Desktop.
get prime number between given range.
start, end = [int(x) for x in input().split()]
sieve = list(range(0,end+1))
primeList = [2]
for i in primeList:
for j in range(i*2, end+1, i):
sieve[j] = 0
for j in range(i+1, end+1):
if sieve[j] != 0:
primeList += [sieve[j]]
break
if 1 in sieve: sieve.remove(1)
sieve = filter(lambda x: x!=0, sieve[start-1:])
for i in sieve:
print(i)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment