If n is not prime, the Jacobi symbol of a, denoted as (a/n), is defined from the Legendre symbol and from the decomposition of n into prime factors. Let
n=p1α 1..pkα k |
where pj is prime and α j is an integer for j=1..k. The Jacobi symbol of a is defined by :
⎛ ⎜ ⎜ ⎝ |
| ⎞ ⎟ ⎟ ⎠ | = | ⎛ ⎜ ⎜ ⎝ |
| ⎞ ⎟ ⎟ ⎠ |
| ... | ⎛ ⎜ ⎜ ⎝ |
| ⎞ ⎟ ⎟ ⎠ |
|
jacobi_symbol takes two arguments a and n, and it returns the Jacobi
symbol (a/n).
Input :
Output :
Input :
Output :
Input :
Output :