Advertisement
paulogp

GCD

Aug 7th, 2011
192
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.18 KB | None | 0 0
  1. # paulogp
  2. def GCD(a, b):
  3.     assert a >= b # a must be the larger number
  4.     while (b != 0):
  5.         remainder = a % b
  6.         a, b  = b, remainder
  7.        
  8.     return a
  9.  
  10. # exemplo
  11. print(GCD(10, 5))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement