For an odd prime $p$, the Legendre symbol $\mathop{(n|p)\/}\nolimits$ is defined as follows. If $p$ divides $n$, then the value of $\mathop{(n|p)\/}\nolimits$ is $0$. If $p$ does not divide $n$, then $\mathop{(n|p)\/}\nolimits$ has the value $1$ when the quadratic congruence $x^{2}\equiv n\;\;(\mathop{{\rm mod}}p)$ has a solution, and the value $-1$ when this congruence has no solution. The Legendre symbol $\mathop{(n|p)\/}\nolimits$, as a function of $n$, is a Dirichlet character (mod $p$). It is sometimes written as $(\frac{n}{p})$. Special values include:
 27.9.1 $\displaystyle\mathop{(-1|p)\/}\nolimits$ $\displaystyle=(-1)^{(p-1)/2},$ Symbols: $\mathop{(n|p)\/}\nolimits$: Legendre symbol and $p$: odd prime Referenced by: §27.9 Permalink: http://dlmf.nist.gov/27.9.E1 Encodings: TeX, pMML, png 27.9.2 $\displaystyle\mathop{(2|p)\/}\nolimits$ $\displaystyle=(-1)^{(p^{2}-1)/8}.$ Symbols: $\mathop{(n|p)\/}\nolimits$: Legendre symbol and $p$: odd prime Referenced by: §27.9 Permalink: http://dlmf.nist.gov/27.9.E2 Encodings: TeX, pMML, png
If $p,q$ are distinct odd primes, then the quadratic reciprocity law states that
 27.9.3 $\mathop{(p|q)\/}\nolimits\mathop{(q|p)\/}\nolimits=(-1)^{(p-1)(q-1)/4}.$ Symbols: $\mathop{(n|p)\/}\nolimits$: Legendre symbol, $p$: odd prime and $q$: odd prime Referenced by: §27.9 Permalink: http://dlmf.nist.gov/27.9.E3 Encodings: TeX, pMML, png
If an odd integer $P$ has prime factorization $P=\prod_{r=1}^{\mathop{\nu\/}\nolimits\!\left(n\right)}p^{a_{r}}_{r}$, then the Jacobi symbol $\mathop{(n|P)\/}\nolimits$ is defined by $\mathop{(n|P)\/}\nolimits=\prod_{r=1}^{\mathop{\nu\/}\nolimits\!\left(n\right)% }{\mathop{(n|p_{r})\/}\nolimits^{a_{r}}}$, with $\mathop{(n|1)\/}\nolimits=1$. The Jacobi symbol $\mathop{(n|P)\/}\nolimits$ is a Dirichlet character (mod $P$). Both (27.9.1) and (27.9.2) are valid with $p$ replaced by $P$; the reciprocity law (27.9.3) holds if $p,q$ are replaced by any two relatively prime odd integers $P,Q$.