login
The OEIS is supported by the many generous donors to the OEIS Foundation.

 

Logo
Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
A034698 a(n) is the smallest prime such that a(1), ..., a(n-1) are squares mod a(n). 3

%I #32 Aug 10 2018 04:19:09

%S 2,7,31,113,233,647,1487,4919,6329,7951,26833,47737,53623,128959,

%T 135697,142327,1312777,3178289,6061607,26564393,32426081,102958417,

%U 209074609,323901311,587709359,1006009759,1029482303,9876033449,11061524183,15821898167,27926616007

%N a(n) is the smallest prime such that a(1), ..., a(n-1) are squares mod a(n).

%H Giovanni Resta, <a href="/A034698/b034698.txt">Table of n, a(n) for n = 1..39</a>

%t 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 *)

%o (Haskell)

%o a034698 n = a034698_list !! (n-1)

%o a034698_list = f [2..] [1] where

%o f (x:xs) ys | a010051' x == 1 &&

%o (and $ map (isSquMod x) ys) = x : f xs (x:ys)

%o | otherwise = f xs ys

%o isSquMod u v = v `mod` u `elem` (map ((`mod` u) . (^ 2)) [0..u-1])

%o -- _Reinhard Zumkeller_, Mar 28 2012

%o (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

%o (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

%Y Cf. A034700.

%Y Cf. A010051, A034791.

%K nonn,nice

%O 1,1

%A E. M. Rains (rains(AT)caltech.edu)

%E More terms from _David W. Wilson_

%E a(25)-a(28) from _Iain Fox_, Aug 08 2018

%E a(29)-a(30) from _Iain Fox_, Aug 09 2018

%E a(31) from _Iain Fox_, Aug 10 2018

Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Style Sheet | Transforms | Superseeker | Recents
The OEIS Community | Maintained by The OEIS Foundation Inc.

License Agreements, Terms of Use, Privacy Policy. .

Last modified March 28 04:13 EDT 2024. Contains 371235 sequences. (Running on oeis4.)