# -*- coding: utf-8 -*-
# Author :Gogh
# @Time :2017/11/14 22:37
# @Email :[email protected]
# 求1-100之间的素数
import math
def sunumber(x):
if x >= 2:
for i in range(2, int(math.sqrt(x)+1)):
if x % i == 0:
return True
return False
list = range(101)
print (filter(sunumber, list)) # 删除1-100之间的素数
# 两种方法
def isnum(num):
i = 2
while i < num:
if num % i == 0:
return 1
else:
i = i + 1
return 0
print (filter(isnum, range(1, 101))) # 删除1-100之间的素数