2023-02-07 13:46:57 -05:00
|
|
|
|
|
|
|
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():
|
2024-07-28 06:25:15 -04:00
|
|
|
num = int(input("Primes up to: "))
|
2023-02-07 13:46:57 -05:00
|
|
|
print()
|
|
|
|
for i in sieve_of_eratosthenes(num):
|
2024-07-28 06:43:01 -04:00
|
|
|
print(i, end=" ")
|
|
|
|
print()
|
2023-02-07 13:46:57 -05:00
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
main()
|