Ⅰ 輸出1000以內的素數及這些素數之和。用Python怎麼做呀
def prime(x):
for i in range(2,x):
if x%i==0:
return False
elif i==x-1:
return True
output=filter(prime,range(2,1001))#區分於map函數
output
b = list(output)
c = 0
for i in b:
c = c + i;
print(c)#我的是jupyter編譯器,如需要展示素數直接print(b)