Skip to main content

Legendre

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

ap=-1ifa0(modp)andthereisnointegerx:ax2(modp),0ifa0(modp),1ifa0(modp)andforsomeintegerx:ax2(modp).

Syntax

legendre(Integer, Integer)

Description

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

arithmetic.legendre.calc.png