%I #31 Oct 04 2021 23:57:26
%S 1,2,6,9,10,13,14,17,19,22,22,26,26,29,31,34,34,37,38,41,43,46,46,53,
%T 53,53,58,58,58,61,62,67,67,71,71,73,74,79,79,82,82,86,86,89,94,94,94,
%U 97,101,101,103,106,106,109,113,113,118,118,118,122,122,127,127,131,131,134
%N Smallest k such that 1, 4, 9, ..., n^2 are distinct mod k.
%C This is the sequence of discriminators of the squares A000290, in the terminology of Arnold et al. - _M. F. Hasler_, May 04 2016
%H T. D. Noe, <a href="/A016726/b016726.txt">Table of n, a(n) for n=1..1000</a>
%H Arnold, L. K.; Benkoski, S. J.; and McCabe, B. J.; <a href="http://www.jstor.org/stable/2323651">The discriminator (a simple application of Bertrand's postulate)</a>. Amer. Math. Monthly 92 (1985), 275-277.
%F For n > 4, a(n) is smallest k >= 2n such that k = p or k = 2p, p a prime.
%t a[n_] := (k = 2n; While[ Not[PrimeQ[k] || PrimeQ[k/2]], k++]; k); a[1]=1; a[2]=2; a[3]=6; a[4]=9; Table[a[n], {n, 1, 66}] (* _Jean-François Alcover_, Nov 30 2011, after formula *)
%t sk[n_]:=Module[{k=2n,n2=Range[n]^2},While[Max[Tally[Mod[n2,k]][[All,2]]]> 1,k++];k]; Join[{1,2},Array[sk,70,3]] (* _Harvey P. Dale_, Oct 16 2016 *)
%o (Haskell)
%o a016726 n = a016726_list !! (n-1)
%o a016726_list = [1,2,6,9] ++ (f 5 $ drop 4 a001751_list) where
%o f n qs'@(q:qs) | q < 2*n = f n qs
%o | otherwise = q : f (n+1) qs'
%o -- _Reinhard Zumkeller_, Jun 20 2011
%o (PARI) A016726_vec(nMax)={my(S=[], a=1); vector(nMax, n, S=concat(S, n^2); while(#Set(S%a)<n, a++); a)} \\ _M. F. Hasler_, May 04 2016
%o (PARI) A016726(n)=if(n>4,min(nextprime(2*n),2*nextprime(n)),[1,2,6,9][n]) \\ _M. F. Hasler_, May 04 2016
%Y Cf. A001751, A192419 (cubes), A192420 (4th powers), A347693.
%K nonn,nice
%O 1,2
%A bernie(AT)wagnerpa.com (Bernie McCabe)