赞
踩
num = [] # 定义一个空列表用来接收找到的符合条件的数字
for i in range(2, 101):
k = 0
for j in range(1, i+1):
if i % j == 0:
k += 1
if k == 2:
num.append(i)
print(num)
方案2:
num = []
i = 2
for i in range(2, 101):
j = 2
for j in range(2, i):
if (i % j == 0):
break
else:
num.append(i)
print(num)
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。