0-10以内质数。Python代码
时间: 2024-02-23 21:02:12 浏览: 94
用python求100以内质数
以下是Python代码实现0-10以内的质数:
```
for num in range(2, 11):
prime = True
for i in range(2, num):
if num % i == 0:
prime = False
break
if prime:
print(num)
```
输出结果为:
```
2
3
5
7
```
阅读全文