python 求1到100之间的素数

list1 = []
i = 2
for i in range(2,101):
    j = 2
    for j in range (2,i):
        if i%j == 0:
            break
    else:
        list1.append(i)
print(list1)
[2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97]

阅读更多
想对作者说点什么? 我来说一句

没有更多推荐了,返回首页