diff options
author | Igor <pashev.igor@gmail.com> | 2011-01-12 15:33:44 +0300 |
---|---|---|
committer | Igor <pashev.igor@gmail.com> | 2011-01-12 15:33:44 +0300 |
commit | cb9ab4e10b97f91bcf78fc643821851097a54e7e (patch) | |
tree | ac08985c2e405a77d7599f0934561cb6acdbd603 /gcd.py | |
download | gcd-cb9ab4e10b97f91bcf78fc643821851097a54e7e.tar.gz |
Begin: C, C#, Haskell, Java, Python
Diffstat (limited to 'gcd.py')
-rwxr-xr-x | gcd.py | 18 |
1 files changed, 18 insertions, 0 deletions
@@ -0,0 +1,18 @@ +#!/usr/bin/env python3 + +import sys +import functools + +def gcd2(a, b): + if b == 0: + return a + else: + return gcd2(b, a % b) + +def gcdn(ns): + return functools.reduce(gcd2, ns) + +ints = map(int, sys.argv[1:]) +gcd = gcdn(ints) +print(gcd) + |