OFFSET
3,1
COMMENTS
There is no quadratic residue > 1 modulo the first or 2nd prime, so the sequence begins with a(3).
LINKS
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
KEYWORD
easy,nonn
AUTHOR
Jonathan Sondow, May 16 2010
STATUS
approved