a = 0
x = 100
for j in range(2, x + 1):
for i in (2, j):
if j % i == 0:
break
else:
a += 1
print(a)
n = 100
a = 0
for x in range(2, n+1):
for i in range(2, x):
if x % i == 0:
break
else:
a += 1
print(a)
这两个代码是一模一样的,但是输出的结果不一样,第一个代码到break那里就不走了,结果显示的是0,第二个就正常这是为什么