Пример #1
0
def legendre(x, y):
    """
    legendre(x, y) -> mpz

    Return the Legendre symbol (x|y). y is assumed to be an odd prime.
    """
    x = _check_mpz('legendre', 'x', x)
    y = _check_mpz('legendre', 'y', y)
    if y <= 0 or not (y % 2):
        raise ValueError('legendre() expected y to be positive and odd')
    return gmp.mpz_legendre(x._mpz, y._mpz)
Пример #2
0
def legendre(x, y):
    """
    legendre(x, y) -> mpz

    Return the Legendre symbol (x|y). y is assumed to be an odd prime.
    """
    x = _check_mpz('legendre', 'x', x)
    y = _check_mpz('legendre', 'y', y)
    if y <= 0 or not (y % 2):
        raise ValueError('legendre() expected y to be positive and odd')
    return gmp.mpz_legendre(x._mpz, y._mpz)
Пример #3
0
def jacobi(x, y):
    """
    jacobi(x, y) -> mpz

    Return the Jacobi symbol (x|y). y must be odd and >0.
    """
    x = _check_mpz('jacobi', 'x', x)
    y = _check_mpz('jacobi', 'y', y)
    if y <= 0 or not (y % 2):
        raise ValueError('jacobi() expected y to be positive and odd')
    return gmp.mpz_legendre(x._mpz, y._mpz)
Пример #4
0
def jacobi(x, y):
    """
    jacobi(x, y) -> mpz

    Return the Jacobi symbol (x|y). y must be odd and >0.
    """
    x = _check_mpz('jacobi', 'x', x)
    y = _check_mpz('jacobi', 'y', y)
    if y <= 0 or not (y % 2):
        raise ValueError('jacobi() expected y to be positive and odd')
    return gmp.mpz_legendre(x._mpz, y._mpz)