[Primes Home][Home]
The Jacobi symbol is \( \left(\frac{a}{p}\right) \). One application area is in the usage of the generalised form (Legendre Symbol) in is the quadratic residue (mod p) [here].
Jacobi symbol
[Primes Home][Home]
The Jacobi symbol is \( \left(\frac{a}{p}\right) \). One application area is in the usage of the generalised form (Legendre Symbol) in is the quadratic residue (mod p) [here].
|
This is a Jacobi symbol is \( \left(\frac{a}{p}\right) \), and is defined as:
\( \left(\frac{a}{p}\right) = \{ \begin{array}{rl} 0 & \text{if } a \equiv 0 \pmod{p},\\1 & \text{if } a \not\equiv 0\pmod{p} \text{ and for some integer } x\colon\;a\equiv x^2\pmod{p},\\-1 & \text{if } a \not\equiv 0\pmod{p} \text{ and there is no such } x. \end{array} \)
Some outline code is:
from libnum import jacobi import sys a=5 b=7 if (len(sys.argv)>1): a=int(sys.argv[1]) if (len(sys.argv)>2): b=int(sys.argv[2]) print ("a=",a) print ("b=",b) c = jacobi(a,b) print ("Jac(a,p)=",c)