summaryrefslogtreecommitdiff
path: root/gcd.py
blob: d6774a06c8671c2aadcd88855d8f13937a29debc (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):
    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)