```python # 求解100或输入数字以内的素数 import math while True: n = int(input("请输入一个数字(>=2):")) if n >= 2: break num = [] for i in range(n): num.append(1) flag = math.floor(math.sqrt(n)) num[0] = 0 i = 1 while i <= flag: if num[i] == 1: for j in range(i+1, n): if (j + 1) % (i + 1) == 0: num[j] = 0 i += 1 reslaut = [] for i in range(n): if num[i] == 1: reslaut.append(i + 1) print(reslaut)