-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.py
More file actions
36 lines (32 loc) · 751 Bytes
/
Copy pathtest.py
File metadata and controls
36 lines (32 loc) · 751 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# def next_prime():
# cur_num = 2
# while True:
# prime = True
# for i in range(2, int(cur_num/2)+1):
# if cur_num%i == 0:
# prime = False
# break
# if prime: yield cur_num
# cur_num += 1
def next_prime():
num = 2
all_primes = set()
while True:
for prime in all_primes:
print(all_primes)
if num % prime == 0:
break
else:
all_primes.add(num)
yield num
num += num % 2 + 1
test = next_prime()
print(next(test))
print(next(test))
print(next(test))
all_primes = set()
print(all_primes)
for prime in all_primes:
if num % prime == 0:
print(num)
break