Implement in Python
This commit is contained in:
parent
ff4632d533
commit
e02319ff24
9 changed files with 59 additions and 2 deletions
1
python/soe/__init__.py
Normal file
1
python/soe/__init__.py
Normal file
|
|
@ -0,0 +1 @@
|
|||
from .main import *
|
||||
26
python/soe/main.py
Normal file
26
python/soe/main.py
Normal 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()
|
||||
Loading…
Add table
Add a link
Reference in a new issue