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.

A354974 Distance LQnR(n) (A334819) from n.

Original entry on oeis.org

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

Views

Author

Joel Brennan, Jun 14 2022

Keywords

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.

Examples

			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.
		

Crossrefs

Programs

  • Mathematica
    a[n_] := n - Max @ Complement[Range[n - 1], Mod[Range[n/2]^2, n]]; Array[a, 100, 3] (* Amiram Eldar, Jun 15 2022 *)
  • PARI
    a(n) = forstep(r = n - 1, 1, -1, if(!issquare(Mod(r, n)), return(n-r))) \\ Thomas Scheuerle, Jun 15 2022