# 输出1-20之间的所有素数
res = []
mark = 0
for i in range(2,20):
for j in range(2,int((i/2)+1)):
if i % j == 0:
mark = 1
if mark == 0:
res.append(i)
mark = 0
print(res) # [2, 3, 5, 7, 11, 13, 17, 19]
标签:输出,20,res,range,mark,素数
来源: https://www.cnblogs.com/leeyong49/p/16655714.html