#coding=utf8
#程式集訓 A009:1-100 質數判別
'''
/*描述 輸入一個正整數,如果是質數,則輸出 Yes,如果不是,則輸出 No。
'''
#==========================
print("1-100 質數判別")
for i in range (2,101):
cnt=0
for j in range (2,i+1):
if (i%j==0) :
cnt=cnt+1
if (cnt==1): #只被整除1次就是質數
print(i,"為質數")
#===========================
Python 3.5.1 (v3.5.1:37a07cee5969, Dec 6 2015, 01:38:48) [MSC v.1900 32 bit (Intel)] on win32
Type "copyright", "credits" or "license()" for more information.
>>>
================= RESTART: D:/程式語言 Python 入門/程式集訓/A009-1.py =================
1-100 質數判別
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 為質數
>>>
訂閱:
張貼留言 (Atom)
邊緣快篩與生成式 AI 智慧環境哨兵(Edge-Cloud AI EnvSentinel)
邊緣快篩與生成式 AI 智慧環境哨兵(Edge-Cloud AI EnvSentinel) 這套系統結合了 Wokwi ESP32 遙測 、 MQTT 傳輸 、 本地 LightGBM 異常快篩 、 SQLite 歷史存檔 、 Gemini 生成式 AI 診斷 與 Telegr...
-
Line 發報機 Python TKinter (CONFIG_LINE Message API_2.py) import serial import serial.tools.list_ports import tkinter as tk from tkinter import...
-
python pip 不是内部或外部命令 -- 解決方法 要安裝 Pyqt5 1. 首先,開啟命令提示字元。 2. 輸入 pip3 install pyqt5 好像不能執行 ! ! 錯誤顯示 : ‘ pip3 ’ 不是內部或外部命令、可執行的程式或批...
-
課程講義 下載 11/20 1) PPT 下載 + 程式下載 http://www.mediafire.com/file/cru4py7e8pptfda/106%E5%8B%A4%E7%9B%8A2-1.rar 11/27 2) PPT 下載...
沒有留言:
張貼留言