1.代码
代码如下:
def shushu(n):
for i in range(2, n):
if n % i == 0:
return 0
return 1
n = int(input("请输入一个数据:"))
value_set = set()
for i in range(2, n):
if shushu(i) == 1:
value_set.add(i)
print(value_set)
2.运行结果
D:\Python代码\Scripts\python.exe C:/Users/Lenovo/PycharmProjects/pythonFirstStart/实验/demo6.py
请输入一个数据:5
{2, 3}
Process finished with exit code 0