初学Python,感觉就想起了c语言的flag那种形式,运行了没问题,不知道还有什么缺陷,如果复制的话注意一下空格
from math import sqrt
flag = True
for n in range(1, 100):
flag = True
if n == 1:
flag = False
# for i in range(2,int(sqrt(n))+1):
for i in range(2, int(n / 2) + 1):
if n % i == 0:
flag = False
if (flag == True):
print(n)