Legendre (problemes fórmula)

Returns the Legendre symbol. Let be an odd prime. An integer is a quadratic residue modulo if it is congruent to a perfect square modelo , and is a quadratic nonresidue modulo otherwise. The Legendre symbol is a function of and defined as

$$\left(\frac ap\right)=\left\{\begin{array}{c}0\;\text{if }\;a\equiv 0\;(\text{mod }p)\\1\text{ if }a\;\not\equiv 0\;(\text{mod }p)\;\text{and for some integer }x:\;a\;\equiv x^2\;(\text{mod }p)\\-1\;\text{if }a\not\equiv 0\;(\text{mod }p)\;\text{and there is no such }x\end{array}\right.$$

legendre(Integer, Integer)

Given an integer and an odd prime , computes the Legendre symbol .

$$\left(\frac ap\right)=\left\{\begin{array}{c}0\;\text{if }\;a\equiv0\;(\text{mod }p)\\1\text{ if }a\;\not\equiv0\;(\text{mod }p)\;\text{and for some integer }x:\;a\;\equiv x^2\;(\text{mod }p)\\-1\;\text{if }a\not\equiv0\;(\text{mod }p)\;\text{and there is no such }x\end{array}\right.$$