实现输出100以内质数的功能
zhishu = []
for num in range(2,100):
if(num == 2):
(2)
for n in range(2,num):
if num % n == 0:
break
else:
if(n==num-1):
(num)
break
print("100以内质数:")
print(zhishu)
输出结果:
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]