0811 coprime test

ph
이동: 둘러보기, 검색
#coprime test
def gcd(m,n):
    while m%n != 0:
        m, n = n, m%n
    return n

def iscoprime(a,b):
    return gcd(a,b) == 1

precisely,

def iscoprime(m,n): # m>n test is not required.
    while m%n != 0:
        m, n = n, m%n
    return n==1

is가 아니고 are인가...

blog comments powered by Disqus