Try this:
sage: Q = quadratic_residues(23); Q [0, 1, 2, 3, 4, 6, 8, 9, 12, 13, 16, 18] sage: N = [x for x in range(22) if kronecker(x,23)==-1]; N [5, 7, 10, 11, 14, 15, 17, 19, 20, 21]
Q is the set of quadratic residues mod 23 and N is the set of non-residues.
Here is another way to construct these using the
kronecker
command (which is also called the
``Legendre symbol''):
sage: [x for x in range(22) if kronecker(x,23)==1] [1, 2, 3, 4, 6, 8, 9, 12, 13, 16, 18] sage: [x for x in range(22) if kronecker(x,23)==-1] [5, 7, 10, 11, 14, 15, 17, 19, 20, 21]
See About this document... for information on suggesting changes.