Previous Up Next

7.1.25  Legendre symbol

If n is prime, the Legendre symbol of a∈ℤ is written (a/n) and defined by:

  


a
n



=



      0if  a≡ 0(mod n ) 
      1if  a ≢0 (mod n )  and  a≡ b2 (mod n )
      −1if  a ≢0 (mod n )  and  a ≢b2 (mod n )
    

The Legendre symbol satisfies the following properties.

The legendre_symbol command computes the Legendre symbol.

Examples

legendre_symbol(26,17)
     
1           
legendre_symbol(27,17)
     
−1           
legendre_symbol(34,17)
     
0           

Previous Up Next