summaryrefslogtreecommitdiff
path: root/gcd.py
blob: 3690ef5c5cc569ea30bc4cdc608460754e004558 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#!/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)