The Jacobi symbol, written or is defined for positive odd as

(1)

where

(2)

is the prime factorization of and is the Legendre symbol.
(The Legendre symbol is equal to depending on whether is a quadratic residue
modulo .)
Therefore, when
is a prime, the Jacobi symbol reduces to the Legendre
symbol. Analogously to the Legendre symbol, the Jacobi symbol is commonly generalized
to have value

(3)

giving

(4)

as a special case. Note that the Jacobi symbol is not defined for or even. The Jacobi symbol is
implemented in the Wolfram Language
as JacobiSymbol[n,
m].