Created
July 28, 2017 10:33
-
-
Save dongho-jung/0e44be0c7b8102a0ff63c890ddc5d8c9 to your computer and use it in GitHub Desktop.
get prime number between given range.
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
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