OFFSET
1,6
FORMULA
a(n) = 2 for n in A057126 and n > 2. - Michel Marcus, Aug 24 2019
EXAMPLE
For n=5, the nonzero quadratic residues modulo 5 are 1 and 4. Since these are both squares we have a(5) = 0.
For n=6, the nonzero quadratic residues modulo 6 are 1,3, and 4. Since 3 is not a square we have a(6) = 3.
For n=10, the nonzero quadratic residues modulo 10 are 1,4,5,6,9. Since 5 is the least nonsquare value, we have a(10) = 5.
MATHEMATICA
a[n_] := SelectFirst[ Union@ Mod[Range[n-1]^2, n], ! IntegerQ@ Sqrt@ # &, 0]; Array[a, 81] (* Giovanni Resta, Aug 13 2019 *)
PROG
(PARI) a(n) = my(v=select(x->issquare(x), vector(n-1, k, Mod(k, n)), 1), y = select(x->!issquare(x), Vec(v))); if (#y, y[1], 0); \\ Michel Marcus, Aug 16 2019
CROSSREFS
KEYWORD
nonn
AUTHOR
John Prosser, Aug 12 2019
STATUS
approved