6.5.24 Legendre symbol: legendre_symbol
If n is prime, the Legendre symbol of a is written
(a/n) and defined by:
⎛
⎜
⎜
⎝ | | ⎞
⎟
⎟
⎠ | = | ⎧
⎪
⎨
⎪
⎩ | 0 | if a=0 modn |
1 | if a ≠ 0 modn and if a=b2 modn |
−1 | if a ≠ 0 modn and if a ≠ b2 modn |
|
|
|
The Legendre symbol satisfies the following properties.
-
If n is prime:
⎛
⎜
⎜
⎝ | | ⎞
⎟
⎟
⎠ | . | ⎛
⎜
⎜
⎝ | | ⎞
⎟
⎟
⎠ |
| = | (−1) | | .(−1) | |
if p and q are odd and positive |
|
| = | |
| = | |
|
The legendre_symbol command computes the Legendre symbol.
-
legendre_symbol takes two arguments:
a and n, integers.
- legendre_symbol(a,n) returns the Legendre
symbol (a/n).
Examples.
-
Input:
legendre_symbol(26,17)
Output:
- Input:
legendre_symbol(27,17)
Output:
- Input:
legendre_symbol(34,17)
Output: