templates/python/nixpkgs/soe/main.py

27 lines
473 B
Python
Raw Normal View History

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():
num = 0
another = True
while another:
try:
2024-07-28 06:01:20 -04:00
num = int(input("Primes up to: "))
2023-02-07 13:46:57 -05:00
another = False
except ValueError:
pass
print()
for i in sieve_of_eratosthenes(num):
print(i)
if __name__ == "__main__":
main()