PyPy ported
The most serious issue was operation priorities :D
$ pypy --version Python 2.7.13 (7.2.0+dfsg-1+dyson1, Dec 04 2019, 16:40:34) [PyPy 7.2.0 with GCC 9.2.1 20191109]
$ cat gcd.py
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)
$ pypy gcd.py 11 22 121 11
Comments