Python Code to Find Two Prime Numbers that Sum to an Even Number
It looks like you are trying to find two prime numbers that add up to an even number 'x'. Here's the corrected code:
b = []
c = []
for m in range(2, y+1):
n = x - m
e = m // 2
f = n // 2
for i in range(2, e+1):
if m % i == 0:
b.append(i)
if len(b) < 1:
for j in range(2, f+1):
if n % j == 0:
c.append(j)
if len(c) < 1:
print('The two prime numbers that add up to ' + str(x) + ' are ' + str(m) + ' and ' + str(n))
Please note that the variables 'x' and 'y' need to be defined before this code block for it to work properly.
原文地址: https://www.cveoy.top/t/topic/m1pU 著作权归作者所有。请勿转载和采集!