Skip to content

Instantly share code, notes, and snippets.

@ZoeyYoung
Created June 6, 2013 06:24
Show Gist options
  • Save ZoeyYoung/5719686 to your computer and use it in GitHub Desktop.
Save ZoeyYoung/5719686 to your computer and use it in GitHub Desktop.
最大公约数
def gcd(i, j):
while i != 0:
if j >= i:
j -= i
else:
i, j = j, i
return j
i = int(raw_input("i:"))
j = int(raw_input("j:"))
print(gcd(i, j))
def isogcd(i, j):
if i == 0: return j
if j == 0: return i
while i != j:
if i > j:
i -= j
else:
j -= i
return i
i = int(raw_input('i:'))
j = int(raw_input('j:'))
print(isogcd(i, j))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment