JACOBI

This function evaluates the Jacobi symbol (m/n) for an integer m and a positive odd integer n. It generalizes the Legendre symbol to composite odd moduli by multiplying Legendre symbols across the prime-power factors of n.

If n = \prod_i p_i^{\alpha_i}, then the Jacobi symbol is:

\left(\frac{m}{n}\right) = \prod_i \left(\frac{m}{p_i}\right)^{\alpha_i}

A result of -1 guarantees nonresiduosity modulo n, while a result of 1 does not always guarantee residuosity when n is composite.

Excel Usage

=JACOBI(m, n)
  • m (int, required): Numerator integer in the Jacobi symbol.
  • n (int, required): Positive odd modulus.

Returns (int): Jacobi symbol value, typically -1, 0, or 1.

Example 1: Jacobi symbol returns negative one

Inputs:

m n
45 77

Excel formula:

=JACOBI(45, 77)

Expected output:

-1

Example 2: Jacobi symbol returns positive one

Inputs:

m n
60 121

Excel formula:

=JACOBI(60, 121)

Expected output:

1

Example 3: Jacobi symbol zero when numerator divisible by modulus factor

Inputs:

m n
14 21

Excel formula:

=JACOBI(14, 21)

Expected output:

0

Example 4: Jacobi with coprime numerator and composite odd modulus

Inputs:

m n
7 45

Excel formula:

=JACOBI(7, 45)

Expected output:

-1

Python Code

from sympy import jacobi_symbol as sympy_jacobi_symbol

def jacobi(m, n):
    """
    Compute the Jacobi symbol for two integers.

    See: https://docs.sympy.org/latest/modules/ntheory.html#sympy.ntheory.residue_ntheory.jacobi_symbol

    This example function is provided as-is without any representation of accuracy.

    Args:
        m (int): Numerator integer in the Jacobi symbol.
        n (int): Positive odd modulus.

    Returns:
        int: Jacobi symbol value, typically -1, 0, or 1.
    """
    try:
        return int(sympy_jacobi_symbol(m, n))
    except Exception as e:
        return f"Error: {str(e)}"

Online Calculator

Numerator integer in the Jacobi symbol.
Positive odd modulus.