In number theory, the Legendre symbol is a function of formula_1 and formula_2 defined as formula_3 where formula_2 is an odd prime number and formula_1 is a positive integer that may or may not be a quadratic residue mod "p". The Legendre symbol is a multiplicative function The Legendre symbol was introduced by Adrien-Marie Legendre in 1797 or 1798 in the course of his attempts at proving the law of quadratic reciprocity. Generalizations of the symbol include the Jacobi symbol and Dirichlet characters of higher order. The notational convenience of the Legendre symbol inspired introduction of several other "symbols" used in algebraic number theory, such as the Hilbert symbol and the Artin symbol. Definition. Legendre's original definition was by means of the explicit formula formula_6 By Euler's criterion, which had been discovered earlier and was known to Legendre, these two definitions are equivalent. Thus Legendre's contribution lay in introducing a convenient "notation" that recorded quadratic residuosity of "a" mod "p". For the sake of comparison, Gauss used the notation "a"R"p", "a"N"p" according to whether "a" is a residue or a non-residue modulo "p". For typographical convenience, the Legendre symbol is sometimes written as ("a" | "p") or ("a"/"p"). For fixed "p", the sequence formula_7 is periodic with period "p" and is sometimes called the Legendre sequence. Each row in the following table exhibits periodicity, just as described. Properties of the Legendre symbol. There are a number of useful properties of the Legendre symbol which, together with the law of quadratic reciprocity, can be used to compute it efficiently. For example, formula_27 Sums of Legendre symbols. Sums of the form formula_28, typically taken over all integers in the range formula_29 for some function formula_30, are a special case of character sums. They are of interest in the distribution of quadratic residues modulo a prime number. Legendre symbol and quadratic reciprocity. Let "p" and "q" be distinct odd primes. Using the Legendre symbol, the quadratic reciprocity law can be stated concisely: formula_31 Many proofs of quadratic reciprocity are based on Euler's criterion formula_32 In addition, several alternative expressions for the Legendre symbol were devised in order to produce various proofs of the quadratic reciprocity law. formula_33 in his fourth and sixth proofs of quadratic reciprocity. formula_34 Reversing the roles of "p" and "q", he obtains the relation between () and (). formula_35 Using certain elliptic functions instead of the sine function, Eisenstein was able to prove cubic and quartic reciprocity as well. Computational example. The above properties, including the law of quadratic reciprocity, can be used to evaluate any Legendre symbol. For example: formula_37 Or using a more efficient computation: formula_38 The article Jacobi symbol has more examples of Legendre symbol manipulation. Since no efficient factorization algorithm is known, but efficient modular exponentiation algorithms are, in general it is more efficient to use Legendre's original definition, e.g. formula_39 using repeated squaring modulo 331, reducing every value using the modulus after every operation to avoid computation with large integers. Table of values. The following is a table of values of Legendre symbol formula_40 with "p" ≤ 127, "a" ≤ 30, "p" odd prime.