Python求100一以内的素数
for i in range(2,100):
a = 0
for m in range(2,i-1):
if i%m == 0:
a=1
break
if a == 0:
print(i," ",end="")#在print中加end="" 可以让print不换行输出
大神代码,一行搞定:
print(" ".join("%s" % x for x in range(2,100) if not [y for y in range(2,x) if x % y ==0]))