题解 | #查找组成一个偶数最接近的两个素数#
查找组成一个偶数最接近的两个素数
https://www.nowcoder.com/practice/f8538f9ae3f1484fb137789dec6eedb9
from math import sqrt def isPrime(num): if num > 1: for i in range(2, int(sqrt(num)) + 1): if num % i == 0: return False return True else: return False while True: try: num = int(input().strip()) pointer = num // 2 result = [] for i in range(pointer, 1, -1): if isPrime(i) and isPrime(num-i): result.append(i) result.append(num-i) break print(result[0]) print(result[1]) except: break