发布网友 发布时间:2022-04-24 04:15
共1个回答
热心网友 时间:2022-04-06 00:52
a = []
f = {}
count=0
# 遍历数字
for i in range(2,2000):
for x in range(2,2000):
if i%x == 0:
f[i] = f.get(i, 0) + 1
# 取出所有质数
for i in f:
if int(f[i]) == 1:
a.append(i)
else:
pass
# 打印所有质数的算法,即偶数等于2个质数之和
for i in a:
for x in a:
l = i + x
if l%2 == 0 and l < 2000 and i >= x:
count+=1
print("%s=%s+%s" %(l,i,x),end=' ')
if count%6==0:
print(end='\n')
在python3.5上运行正常。