Legendre (problemes fórmula)

Returns the Legendre symbol. Let p be an odd prime. An integer a is a quadratic residue modulo p if it is congruent to a perfect square modelo p, and is a quadratic nonresidue modulo p otherwise. The Legendre symbol is a function of a and p 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 a and an odd prime p, computes the Legendre symbol open parentheses a over p close parentheses.

Jacobi (problemes formula), Lucas

$$\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.$$