Created
October 8, 2016 08:16
-
-
Save yevgnenll/0d1f57f5ddbfe663ca786992aa86db6b to your computer and use it in GitHub Desktop.
This file contains hidden or 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 = map(int, input().split()) | |
def erathos(start, end): | |
numbers = [False for _ in range(end+1)] | |
prime_numbers = [] | |
numbers[0] = True | |
numbers[1] = True | |
for num, prime in enumerate(numbers): | |
if prime: | |
continue | |
prime_numbers.append(num) | |
for i in range(num*num, end+1, num): | |
numbers[i] = True | |
print_primes(prime_numbers, start) | |
def is_prime(num): | |
if num < 2 : | |
return False | |
for i in range(2, num): | |
if i*i > num: | |
break | |
if num % i == 0: | |
return False | |
return True | |
def print_primes(arr, start): | |
for i in arr: | |
if i >= start: | |
print(i) | |
erathos(start, end) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment