题解 | #查找组成一个偶数最接近的两个素数#
查找组成一个偶数最接近的两个素数
http://www.nowcoder.com/practice/f8538f9ae3f1484fb137789dec6eedb9
# -*-coding:utf-8-*-
def ispri(num):
if num<=1:
return False
for i in range(2,int(num**0.5)+1):
if num%i==0:
return False
else:
return True
while True:
try:
input_n = int(input())
k=[]
for i in range(1,input_n//2+1):
if ispri(i) and ispri(input_n-i):
k.append((i,(input_n-i)))
#print(k)
x = []
for i,j in k:
xx = abs(i - j)
x.append(xx)
sorted(x)
#print(x[-1])
for i in range(1,input_n//2+1):
if (x[-1]==(input_n-i-i)) and ispri(i):
print("%d\n%d" %(i,input_n-i))
except:
break