

def crt(a_values, modulo_values):
    'Chinese Remainder Theorem.\n\n    Calculates x such that x = a[i] (mod m[i]) for each i.\n\n    :param a_values: the a-values of the above equation\n    :param modulo_values: the m-values of the above equation\n    :returns: x such that x = a[i] (mod m[i]) for each i\n    \n\n    >>> crt([2, 3], [3, 5])\n    8\n\n    >>> crt([2, 3, 2], [3, 5, 7])\n    23\n\n    >>> crt([2, 3, 0], [7, 11, 15])\n    135\n    '
    m = 1
    x = 0
    for modulo in modulo_values:
        m *= modulo
    for (m_i, a_i) in zip(modulo_values, a_values):
        M_i = (m // modulo_values)
        inv = inverse(M_i, m_i)
        x = ((x + ((a_i * M_i) * inv)) % m)
    return x

dataset/ETHPy150Open CouchPotato/CouchPotatoServer/libs/rsa/common.py crt/VarMisuse@55/299 `m_i`->`modulo_values`