login
A177864
a(n) is the smallest nontrivial quadratic residue modulo prime(n), for n >= 3.
0
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,1
COMMENTS
There is no quadratic residue > 1 modulo the first or 2nd prime, so the sequence begins with a(3).
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.
EXAMPLE
The quadratic residues modulo prime(3) = 5 are 1 and 4, so a(3) = 4.
MATHEMATICA
Flatten[Table[ Extract[Flatten[ Position[Table[JacobiSymbol[i, Prime[n]], {i, 1, Prime[n] - 1}], 1]], {2}], {n, 3, 100}]]
PROG
(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
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)).
Sequence in context: A307367 A136626 A079623 * A090112 A226087 A118945
KEYWORD
easy,nonn
AUTHOR
Jonathan Sondow, May 16 2010
STATUS
approved