What is the most efficient ("pythonic") way to test/check if two numbers are co-primes (relatively prime) in Python.
For the moment I have this code:
def gcd(a, b):
while b != 0:
a, b = b, a % b
return a
def coprime(a, b):
return gcd(a, b) == 1
print(coprime(14,15)) #Should be true
print(coprime(14,28)) #Should be false
Can the code for checking/testing if two numbers are relatively prime be considered "Pythonic" or there is some better way?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…