题解 | #查找组成一个偶数最接近的两个素数#
查找组成一个偶数最接近的两个素数
https://www.nowcoder.com/practice/f8538f9ae3f1484fb137789dec6eedb9
from sre_constants import INFO # 定义素数判断函数 def isPrimme(num): for i in range(2,int(num**0.5)+1): if num % i == 0: return False else: pass return True n = int(input()) mindis = n for i in range(2,n+1): if isPrimme(i) and isPrimme(n-i): if abs(n-i-i) < mindis: a,b = i,n-i mindis = abs(n-i-i) print(a) print(b)