Quadratic Residues
Let n be a positive integer and let a be an integer such that gcd(a,n)=1.
a is said to be a quadratic residue modulo n if and only if there exists a x such that: x2≡a(modn)
When n is a prime number (n=p) there exist three cases:
either a is a multiple of p, or
a is a quadratic residue, or
a is not a quadratic residue.
The Legendre symbol (pa) captures this as follows.

Legendre Symbol


Jacobi Symbol

Counts
For a prime p, the number of integers belonging to the set [1,2,...,p−1] that are quadratic residues is exactly (p−1)/2.
How about composite numbers that are the product of two distinct prime numbers?
Square Roots

Example:
Factorization

Example (continuation of the code of the previous slide):
pari-gp can only compute square roots when the modulus is prime:
Last updated