题解 | #查找组成一个偶数最接近的两个素数#
查找组成一个偶数最接近的两个素数
https://www.nowcoder.com/practice/f8538f9ae3f1484fb137789dec6eedb9
def check_num(x): #确认是否是素数 result = True if x in [1,2]: return result for i in range(2,x): if x%i == 0: result = False return result def analy(x): #返回需要的素数 pool = [] for i in range(1,int(x/2)+1): if check_num(i) and check_num(x-i): pool.append(i) tmp = x for i in pool: if int(x/2)-i <= tmp: tmp = int(x/2)-i return (int(x/2) - tmp) while True: try: data = int(input()) except: break else: b = analy(data) print(b) print(data-b)