# 用for循环实现1~100中的质数求和
sum = 0
for x in range(2, 101):
for i in range(2, x):
if x % i == 0:
break
else:
print('%d 是个素数' % x)
sum += x
print(' 1 ~ 100 所有素数的和为:', sum)
07-21
403
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
02-14
1636
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
08-19
1万+
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
06-30
1467
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
03-18
5294
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)