方法一,用for循环来实现
num=[];
i=2
for i in range(2,100):
j=2
for j in range(2,i):
if(i%j==0):
break...x: not [x%i for i in range(2, int(math.sqrt(x))+1) if x%i ==0], range(2,n+1))
print func_get_prime(100...)
输出结果为:
[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]
实例补充:
def all_prime(num):
lst = []
if num <= 1:
return '0 ~ %d以内没有任何素数' % num
for i in range...以内的素数的文章就介绍到这了,更多相关如何用python求100以内的素数内容请搜索ZaLou.Cn