--- title: 20-5:最大公因數 lang: zh-tw tags: DICE Python --- 20-5:最大公因數 === > [name=Chinglin-K] --- 目錄:[Dice 程式教學-Python完整版](https://hackmd.io/@Chinglin-K/Dice-menu) 上一篇:[20-4:遞迴數列](https://hackmd.io/@Chinglin-K/Dice-20-4) 下一篇:[21-1:印出動物元素](https://hackmd.io/@Chinglin-K/Dice-21-1) --- ## 題目 使用者輸入兩個整數,找出最大公因數。 輸入範例: 6 18 輸出範例: 6 --- ## 程式碼 ```Python= def Euc(a,b): if(a==0 or b==0): if(a>=b): return a else: return b if(a>=b): a=a%b else: b=b%a return Euc(a,b) a=int(input()) b=int(input()) print(Euc(a,b)) ``` --- ## 輸出 ```Python= ``` --- 目錄:[Dice 程式教學-Python完整版](https://hackmd.io/@Chinglin-K/Dice-menu) 上一篇:[20-4:遞迴數列](https://hackmd.io/@Chinglin-K/Dice-20-4) 下一篇:[21-1:印出動物元素](https://hackmd.io/@Chinglin-K/Dice-21-1) --- :::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