summaryrefslogtreecommitdiff
path: root/gcd.py
blob: df3baf64db60e0c05e20ac10c2cafb588f655a11 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#!/usr/bin/env python3

import sys
import functools


def gcd2(a, b):
    while b != 0:
        a, b = b, a % b
    return a


def gcdn(nums):
    return functools.reduce(gcd2, nums)


if len(sys.argv) > 1:
    print(gcdn(map(int, sys.argv[1:])))