发布网友 发布时间:2022-04-18 07:57
共1个回答
热心网友 时间:2022-04-18 09:26
代码如下,缩进请参考截图:
def is_prime(n):
if n == 1:
return False
for i in range(2, int(n ** 0.5) + 1):
if n % i == 0:
return False
return True
prime = [ i for i in range(1,1001) if is_prime(i) ]
for i in range(2,1001):
if i % 2 == 0:
for x in prime:
if i - x in prime:
print('{} + {} = {}'.format(i-x,x,i))
break
输出节选: