Kiana Sheibani
a3b53b180c
Instead of separating output primes by newline, the scripts now separate by spaces.
19 lines
349 B
Python
19 lines
349 B
Python
|
|
def sieve_of_eratosthenes(n):
|
|
nums = list(range(2, n))
|
|
while nums:
|
|
prime = nums[0]
|
|
nums = [i for i in nums if i % prime]
|
|
yield prime
|
|
|
|
def main():
|
|
num = int(input("Primes up to: "))
|
|
print()
|
|
for i in sieve_of_eratosthenes(num):
|
|
print(i, end=" ")
|
|
print()
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|