The theory of quadratic residues is one of the great triumphs of the classical period of number theory. An integer k that is prime to a positive integer m is said to be a quadratic residue modulo m if there exists z ∈ Z such that

z2 ≡ k (modm). Denoting the residue class of k modulo m by k¯, this can be rephrased as: k¯ is both a unit and a square in Zm.