题解 | #查找组成一个偶数最接近的两个素数#
查找组成一个偶数最接近的两个素数
https://www.nowcoder.com/practice/f8538f9ae3f1484fb137789dec6eedb9
def isprime(n): flag = True if n == 1 or (n%2==0 and n!=2): flag = False else: p_max = int(pow(n,1/2)) for i in range(3,p_max+1): if n%i == 0: flag = False break return flag n = int(input()) v1 = n//2 while v1>=2: v2 = n-v1 if isprime(v1) and isprime(v2): break v1 -=1 for x in [v1,v2]: print(x)