rodrigosantosbr

[Py] Euclid algorithm (MDC)

Feb 16th, 2019
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.27 KB | None | 0 0
  1. # maior divisor comum (mdc)
  2. # 60 - 50 = 10
  3. # 50 - 10 = 40
  4. # 40 - 10 = 30
  5. # 30 - 10 = 20
  6. # 20 - 10 = 10
  7. # 10 - 10 = 0
  8. def euclid(a, b):
  9.     return b and euclid(b, a % b) or a
  10.  
  11. # The largest common divisor between the numbers 50 and 60 is 10.
  12. x = euclid(60,50)
  13. print(x)
Advertisement
Add Comment
Please, Sign In to add comment