-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path46.py
44 lines (40 loc) · 832 Bytes
/
46.py
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
37
38
39
40
41
42
43
44
def is_comp(n):
for i in range(3, int(n**0.5)+2, 2):
if n % i == 0:
return True
return False
def twice_square(n):
i = 1
ts = 2 * i * i
tsl = []
while (ts < n):
tsl.append(ts)
i += 1
ts = 2 * i * i
return tsl
def is_prime(n):
if n <= 1:
return False
elif n <= 3:
return True
elif n % 2 == 0 or n % 3 == 0:
return False
i = 5
while i * i <= n:
if (n % i == 0 or n % (i + 2) == 0):
return False
i += 6
return True
i = 9
while True:
if is_comp(i):
tsl = twice_square(i)
found = 0
for ts in tsl:
if is_prime(i - ts):
found = 1
break
if not found:
print(i)
break
i += 2