Jacobi symbol: jacobi_symbol

### 6.5.26 Jacobi symbol: jacobi_symbol

The Jacobi symbol is a generalization of the Legendre symbol (a/n) for when n isn’t prime. Let

n=p1α 1… pkα k

be the prime factorization of n. The Jacobi symbol of a is defined by:

⎛ ⎜ ⎜ ⎝ |
a
n
| ⎞ ⎟ ⎟ ⎠ | = | ⎛ ⎜ ⎜ ⎝ |
a
p1
| ⎞ ⎟ ⎟ ⎠ |
α1
| … | ⎛ ⎜ ⎜ ⎝ |
a
pk
| ⎞ ⎟ ⎟ ⎠ |
α k

Where the left hand side is the Jacobi symbol and the right hand side contains Legendre symbols. The jacobi_symbol command computes the Jacobi symbol.

- jacobi_symbol takes two arguments:
  a and n, integers.
- jacobi_symbol(a,n) returns the Jacobi symbol (a/n).

Examples.

- Input:
  jacobi_symbol(25,12)
  Output:

  1

- Input:
  jacobi_symbol(35,12)
  Output:

  −1

- Input:
  jacobi_symbol(33,12)
  Output:

  0