100以内的素数Python
时间: 2023-08-31 22:11:23 浏览: 35
流程描述-python求出0~100以内的所有素数
以下是Python代码实现:
```python
primes = []
for num in range(2, 100):
for i in range(2, num):
if num % i == 0:
break
else:
primes.append(num)
print(primes)
```
输出结果为:
```
[2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97]
```
阅读全文