cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

A177864 a(n) is the smallest nontrivial quadratic residue modulo prime(n), for n >= 3.

Original entry on oeis.org

4, 2, 3, 3, 2, 4, 2, 4, 2, 3, 2, 4, 2, 4, 3, 3, 4, 2, 2, 2, 3, 2, 2, 4, 2, 3, 3, 2, 2, 3, 2, 4, 4, 2, 3, 4, 2, 4, 3, 3, 2, 2, 4, 2, 4, 2, 3, 3, 2, 2, 2, 3, 2, 2, 4, 2, 3, 2, 4, 4, 4, 2, 2, 4, 4, 2, 3, 3, 2, 2, 2, 3, 4, 2, 4, 3, 2, 2, 3, 3, 2, 2, 2, 3, 2, 2, 4, 2, 3, 2, 2, 3, 4, 2, 4, 2, 4, 3
Offset: 3

Views

Author

Jonathan Sondow, May 16 2010

Keywords

Comments

There is no quadratic residue > 1 modulo the first or 2nd prime, so the sequence begins with a(3).

Examples

			The quadratic residues modulo prime(3) = 5 are 1 and 4, so a(3) = 4.
		

Crossrefs

Cf. A063987 (triangle in which the n-th row gives the quadratic residues modulo prime(n)), A053760 (smallest positive quadratic nonresidue modulo prime(n)).

Programs

  • Mathematica
    Flatten[Table[ Extract[Flatten[ Position[Table[JacobiSymbol[i, Prime[n]], {i, 1, Prime[n] - 1}], 1]], {2}], {n, 3, 100}]]
  • PARI
    a(n,p=prime(n))=[2,0,0,0,4,0,2,0,0,0,3,0,3,0,0,0,2,0,4,0,0,0,2][p%24] \\ Charles R Greathouse IV, Jun 14 2022

Formula

a(n) = 2 or 3 or 4 according as prime(n) == 1,7,9,15,17,23 or 11,13 or 3,5,19,21 (mod 24), respectively, for n > 2, by the quadratic reciprocity law and its supplements.