For an odd prime $p$, the Legendre symbol $(n|p)$ is defined as follows. If $p$ divides $n$, then the value of $(n|p)$ is $0$. If $p$ does not divide $n$, then $(n|p)$ has the value $1$ when the quadratic congruence $x^{2}\equiv n\pmod{p}$ has a solution, and the value $-1$ when this congruence has no solution. The Legendre symbol $(n|p)$, 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(-1|p)$ $\displaystyle=(-1)^{(p-1)/2},$ ⓘ Symbols: $(\NVar{n}|\NVar{p})$: Legendre symbol and $p$: odd prime Referenced by: §27.9 Permalink: http://dlmf.nist.gov/27.9.E1 Encodings: TeX, pMML, png See also: Annotations for §27.9 and Ch.27 27.9.2 $\displaystyle(2|p)$ $\displaystyle=(-1)^{(p^{2}-1)/8}.$ ⓘ Symbols: $(\NVar{n}|\NVar{p})$: Legendre symbol and $p$: odd prime Referenced by: §27.9 Permalink: http://dlmf.nist.gov/27.9.E2 Encodings: TeX, pMML, png See also: Annotations for §27.9 and Ch.27
If $p,q$ are distinct odd primes, then the quadratic reciprocity law states that
 27.9.3 $(p|q)(q|p)=(-1)^{(p-1)(q-1)/4}.$ ⓘ Symbols: $(\NVar{n}|\NVar{p})$: 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 See also: Annotations for §27.9 and Ch.27
If an odd integer $P$ has prime factorization $P=\prod_{r=1}^{\nu\left(n\right)}p^{a_{r}}_{r}$, then the Jacobi symbol $(n|P)$ is defined by $(n|P)=\prod_{r=1}^{\nu\left(n\right)}{(n|p_{r})}^{a_{r}}$, with $(n|1)=1$. The Jacobi symbol $(n|P)$ 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$.