This site is supported by donations to The OEIS Foundation.

# Legendre symbol

The Legendre symbol ${\displaystyle \scriptstyle \left({\frac {a}{p}}\right)\,}$, introduced by Adrien-Marie Legendre in 1798, is a multiplicative arithmetic function that gives 0 if ${\displaystyle a}$ is divisible by the odd prime ${\displaystyle p}$, otherwise gives –1 if ${\displaystyle a}$ is a quadratic nonresidue modulo ${\displaystyle p}$ and +1 if ${\displaystyle a}$ is a quadratic residue modulo ${\displaystyle p}$.
${\displaystyle \left({\frac {a}{p}}\right)={\begin{cases}-1{\text{ if }}a{\text{ is a quadratic nonresidue modulo }}p,\\\;\;\,0{\text{ if }}a\equiv 0{\pmod {p}},\\\;\;\,1{\text{ if }}a{\text{ is a quadratic residue modulo }}p{\text{ and }}a\not \equiv 0{\pmod {p}}.\\\end{cases}}}$
${\displaystyle \left({\frac {4}{7}}\right)=1}$
${\displaystyle \left({\frac {5}{7}}\right)=-1}$