OFFSET
1,2
COMMENTS
After 2880, 3360 has exactly the same density (5%).
LINKS
Keith F. Lynch, Table of n, a(n) for n = 1..200 (terms 1..111 from Hugo Pfoertner)
Andreas Enge, William Hart, Fredrik Johansson, Short addition sequences for theta functions, arXiv:1608.06810 [math.NT], 2016-2018.
EXAMPLE
a(3)=4 because for B=4 the different quadratic residues are {0,1}, so S=2, the density is D_4=50%, which is smaller than D_2=100% and D_3=66.67%.
MATHEMATICA
Block[{s = Range[0, 2^14 + 1]^2, t}, t = Array[#/Length@ Union@ Mod[Take[s, # + 1], #] &, Length@ s - 1]; Map[FirstPosition[t, #][[1]] &, Union@ FoldList[Max, t]]] (* Michael De Vlieger, Sep 10 2018 *)
PROG
(PARI) r=-1; for(n=1, 1e6, t=1-sum(k=1, n, issquare(Mod(k, n)))/n; if(t>r, r=t; print1(n", "))) \\ Charles R Greathouse IV, Jul 15 2011
(PARI) sq1(m)=sum(n=0, m-1, issquare(Mod(n, m)))
sq(n, f=factor(n))=prod(i=1, #f~, my(p=f[i, 1], e=f[i, 2]); if(e>1, sq1(p^e), p\2+1))
r=2; for(n=1, 1e6, t=sq(n)/n; if(t<r, r=t; print1(n", "))) \\ Charles R Greathouse IV, Mar 30 2018
CROSSREFS
KEYWORD
nonn
AUTHOR
Jose R. Brox (tautocrona(AT)terra.es), Jul 10 2003
EXTENSIONS
More terms from Jud McCranie, Jul 12 2003
a(1) and PARI programs corrected by Hugo Pfoertner, Aug 23 2018
STATUS
approved