login

Year-end appeal: Please make a donation to the OEIS Foundation to support ongoing development and maintenance of the OEIS. We are now in our 61st year, we have over 378,000 sequences, and we’ve reached 11,000 citations (which often say “discovered thanks to the OEIS”).

A354974
Distance LQnR(n) (A334819) from n.
1
1, 1, 2, 1, 1, 1, 1, 2, 1, 1, 2, 1, 1, 1, 3, 1, 1, 1, 1, 1, 1, 1, 2, 2, 1, 1, 2, 1, 1, 1, 1, 3, 1, 1, 2, 1, 1, 1, 3, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 2, 1, 1, 1, 1, 2, 1, 1, 2, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 5, 2, 1, 1, 1, 1, 1, 1, 1, 3, 1, 1, 2, 1, 1, 1, 3, 1, 1, 1, 1, 1, 1, 1, 5, 1, 1, 1
OFFSET
3,3
COMMENTS
a(n) is the distance between n and the largest quadratic nonresidue modulo n: a(n) = n - A334819(n). So n - a(n) is the largest nonsquare modulo n.
LINKS
EXAMPLE
The nonsquares modulo 8 are 2, 3, 5, 6, and 7, so the distance of the largest quadratic nonresidue from 8 is a(8) = 1. The quadratic nonresidues modulo 17 are 3, 5, 6, 7, 10, 11, 12, and 14, so a(17) = 17 - 14 = 3.
MATHEMATICA
a[n_] := n - Max @ Complement[Range[n - 1], Mod[Range[n/2]^2, n]]; Array[a, 100, 3] (* Amiram Eldar, Jun 15 2022 *)
PROG
(PARI) a(n) = forstep(r = n - 1, 1, -1, if(!issquare(Mod(r, n)), return(n-r))) \\ Thomas Scheuerle, Jun 15 2022
CROSSREFS
KEYWORD
nonn,easy
AUTHOR
Joel Brennan, Jun 14 2022
STATUS
approved