def inverse(x, n):

    (divider, inv, _) = extended_gcd(x, n)

    if divider != 1:
        raise ValueError("x (%d) and n (%d) are not relatively prime" % (x, n))

    return inv
Returns x^-1 (mod n)
dataset/ETHPy150Open CouchPotato/CouchPotatoServer/libs/rsa/common.py/inverse