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 modulo p, and is a quadratic nonresidue modulo p otherwise. The Legendre symbol is a function of a and p defined as

Error converting from MathML to accessible text.

legendre(Integer, Integer)

Given an integer a and an odd prime p, computes the Legendre symbol open parentheses a over p close parentheses.