判断质数
#任意质数 def zhishu(n): if n < 2: return False for i in range(2, n): if n % i == 0: return False return True for i in range(2, 101): if zhishu(i): print(i,end=" ")
def pri(n,m):
ret = []
for i in range(n,m+1):
for j in range(2,i):
if i % j == 0:
break
else:
if i >1:
ret.append(i)
return ret
print(pri(-221,200))
#找出100到200的质数 # def pri(n,m): # ret = [] # for i in range(n,m+1): # for j in range(2,i): # if i % j == 0: # b = i # ret.append(b) # return ret # a = set(range(100,201)) # print(a-set(pri(100,200))) # def pri(n,m): # ret = [] # for i in range(n,m+1): # for j in range(2,i): # if i % j == 0: # break # else: # ret.append(i) # return ret # print(pri(100,200))