- start=int(input("從"))
- end=int(input("到"))
- list=[]
- count=0
- for num in range(start,(end+1)):
- list.append(num)
- print("這些:",list)
- print("是質數的:", end="")
- for idx in range(0,len(list)):
- for i in range(1,(list[idx]+1)):
- if list[idx]%i==0:
- count+=1
- if count==2:
- print(list[idx], end=" ")
- count=0
-
- del count
複製代碼 |