If n is prime, the Legendre symbol of a∈ℤ is written (a/n) and defined by:
| ⎛ ⎜ ⎜ ⎝ | 
 | ⎞ ⎟ ⎟ ⎠ | = | ⎧ ⎪ ⎨ ⎪ ⎩ | 
 | 
The Legendre symbol satisfies the following properties.
| ⎛ ⎜ ⎜ ⎝ | 
 | ⎞ ⎟ ⎟ ⎠ | . | ⎛ ⎜ ⎜ ⎝ | 
 | ⎞ ⎟ ⎟ ⎠ | =(−1) | 
 | .(−1) | 
 | , | ⎛ ⎜ ⎜ ⎝ | 
 | ⎞ ⎟ ⎟ ⎠ | =(−1) | 
 | , | ⎛ ⎜ ⎜ ⎝ | 
 | ⎞ ⎟ ⎟ ⎠ | =(−1) | 
 | . | 
The legendre_symbol command computes the Legendre symbol.
| legendre_symbol(26,17) | 
| 
 | 
| legendre_symbol(27,17) | 
| 
 | 
| legendre_symbol(34,17) | 
| 
 |