count = 0 for n in range(1,101): flag=1 for m in range(2,n): if n%m==0: flag=0 break if flag==1: #print(n) print("%5d" % n,end="") count=count+1 if count%5==0: print()
双层循环打印出1~100中的所有素数
最新推荐文章于 2024-08-24 11:00:49 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)
count = 0 for n in range(1,101): flag=1 for m in range(2,n): if n%m==0: flag=0 break if flag==1: #print(n) print("%5d" % n,end="") count=count+1 if count%5==0: print()