diff options
author | Igor Pashev <pashev.igor@gmail.com> | 2022-11-07 16:58:28 +0200 |
---|---|---|
committer | Igor Pashev <pashev.igor@gmail.com> | 2022-11-07 16:58:28 +0200 |
commit | e63c05e65d2e4c55719186df30ab24cdb9754239 (patch) | |
tree | a9be7c325f30487c4aadea66cc7372c1b48c4af9 | |
parent | 90b77e76146a4f47f7208853ee7de7d7fdf55945 (diff) | |
download | gcd-e63c05e65d2e4c55719186df30ab24cdb9754239.tar.gz |
Update Python
-rwxr-xr-x | gcd.py | 16 |
1 files changed, 7 insertions, 9 deletions
@@ -5,16 +5,14 @@ import functools def gcd2(a, b): - if b == 0: - return a - else: - return gcd2(b, a % b) + while b != 0: + a, b = b, a % b + return a -def gcdn(ns): - return functools.reduce(gcd2, ns) +def gcdn(nums): + return functools.reduce(gcd2, nums) -ints = map(int, sys.argv[1:]) -gcd = gcdn(ints) -print(gcd) +if len(sys.argv) > 1: + print(gcdn(map(int, sys.argv[1:]))) |