--- title: 17-8:找因數 lang: zh-tw tags: DICE Python --- 17-8:找因數 === > [name=Chinglin-K] --- 目錄:[Dice 程式教學-Python完整版](https://hackmd.io/@Chinglin-K/Dice-menu) 上一篇:[17-7:上題做x次](https://hackmd.io/@Chinglin-K/Dice-17-7) 下一篇:[17-9:印圖形1](https://hackmd.io/@Chinglin-K/Dice-17-9) --- ## 題目 給一個整數,列出其所有的正因數,程序可重複執行,直至整數小於等於0為止。 輸入資料: 10 9 255 68 -999 輸出資料: 1 2 5 10 1 3 9 1 3 5 15 17 51 85 255 1 2 4 17 34 68 --- ## 程式碼 ```Python= try: while True: n=int(input()) if(n<=0): break else: for i in range(1,n+1): if(n%i==0): print(i,end=" ") print("") except: pass ``` --- ## 輸出 ```Python= ``` --- 目錄:[Dice 程式教學-Python完整版](https://hackmd.io/@Chinglin-K/Dice-menu) 上一篇:[17-7:上題做x次](https://hackmd.io/@Chinglin-K/Dice-17-7) 下一篇:[17-9:印圖形1](https://hackmd.io/@Chinglin-K/Dice-17-9) --- :::info 「盡多少本分,得多少本事」😊 ::: --- {%hackmd i1nMRrZcTFmTvoF897K9zg %}
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up