Skip to content

Instantly share code, notes, and snippets.

@thuandt
Created January 17, 2013 01:02
Show Gist options
  • Save thuandt/4552592 to your computer and use it in GitHub Desktop.
Save thuandt/4552592 to your computer and use it in GitHub Desktop.
import sys
def gcd(a, b):
t = b
b = a % b
if b == 0:
return t
else:
return gcd(t, b)
def main(argv):
if (len(sys.argv) != 3):
sys.exit('Usage: gcd.py <a> <b>')
print abs(gcd(int(sys.argv[1]), int(sys.argv[2])))
if __name__ == "__main__":
main(sys.argv[1:])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment