Implement in Python

This commit is contained in:
Kiana Sheibani 2023-02-07 13:46:57 -05:00
parent ff4632d533
commit e02319ff24
Signed by: toki
GPG key ID: 6CB106C25E86A9F7
9 changed files with 59 additions and 2 deletions

1
python/soe/__init__.py Normal file
View file

@ -0,0 +1 @@
from .main import *

26
python/soe/main.py Normal file
View file

@ -0,0 +1,26 @@
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:
num = int(input())
another = False
except ValueError:
pass
print()
for i in sieve_of_eratosthenes(num):
print(i)
if __name__ == "__main__":
main()