OFFSET
1,1
LINKS
Giovanni Resta, Table of n, a(n) for n = 1..39
MATHEMATICA
residueQ[n_, p_] := JacobiSymbol[n, p] == 1; a[1] = 2; a[n_] := a[n] = For[r = Range[n - 1]; p = NextPrime[a[n - 1]], True, p = NextPrime[p], If[AllTrue[r, residueQ[a[#], p] &], Return[p]]]; Table[Print["a(", n, ") = ", a[n]]; a[n], {n, 1, 24}] (* Jean-François Alcover, Feb 16 2018 *)
PROG
(Haskell)
a034698 n = a034698_list !! (n-1)
a034698_list = f [2..] [1] where
f (x:xs) ys | a010051' x == 1 &&
(and $ map (isSquMod x) ys) = x : f xs (x:ys)
| otherwise = f xs ys
isSquMod u v = v `mod` u `elem` (map ((`mod` u) . (^ 2)) [0..u-1])
-- Reinhard Zumkeller, Mar 28 2012
(PARI) first(n) = my(res=vector(n)); res[1]=2; for(x=2, n, forprime(p=res[x-1]+1, , for(y=1, x-1, if(!issquare(Mod(res[y], p)), next(2))); res[x]=p; break())); res \\ Iain Fox, Aug 08 2018
(PARI) nextterm(v) = forprime(p=v[#v]+1, , for(y=1, #v, if(!issquare(Mod(v[y], p)), next(2))); return(p)) \\ (Inserting a vector of the first n-1 terms will return the n-th term) Iain Fox, Aug 08 2018
CROSSREFS
KEYWORD
nonn,nice
AUTHOR
E. M. Rains (rains(AT)caltech.edu)
EXTENSIONS
More terms from David W. Wilson
a(25)-a(28) from Iain Fox, Aug 08 2018
a(29)-a(30) from Iain Fox, Aug 09 2018
a(31) from Iain Fox, Aug 10 2018
STATUS
approved