-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexer12.py
More file actions
30 lines (25 loc) · 703 Bytes
/
exer12.py
File metadata and controls
30 lines (25 loc) · 703 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
class PrimeNumberDigit:
def __init__(self, num):
self.num = num
self.cur = num
def __iter__(self):
return self
def __next__(self):
while True:
if str(self.num) in str(self.cur) and self.is_prime(self.cur):
prime_num = self.cur
self.cur += 1
return prime_num
else:
self.cur += 1
def is_prime(self,num):
if num < 2:
return False
for element in range(2, num):
if num % element == 0:
return False
return True
div = PrimeNumberDigit(13)
print(next(div))
print(next(div))
print(next(div))