gcd. , gcd, math ( Python 3.5), .
coprime2, gcd:
from math import gcd as bltin_gcd
def coprime2(a, b):
return bltin_gcd(a, b) == 1
- , math.gcd C (. math_gcd mathmodule.c):
%timeit coprime(14, 15)
1000000 loops, best of 3: 907 ns per loop
%timeit coprime2(14, 15)
1000000 loops, best of 3: 486 ns per loop
Python <= 3.4 fractions.gcd, , @user2357112, C. , , , .