A269254 To find a(n), define a sequence by s(k) = n*s(k-1) - s(k-2), with s(0) = 1, s(1) = n + 1; then a(n) is the smallest index k such that s(k) is prime, or -1 if no such k exists.
1, 1, 2, 1, 2, 1, -1, 2, 2, 1, 2, 1, 2, -1, 2, 1, 3, 1, 2, 2, 2, 1, -1, 2, 6, 2, 3, 1, 3, 1, 2, 9, 9, -1, 2, 1, 6, 2, 2, 1, 2, 1, 5, 2, 2, 1, -1, 2, 5, 2, 9, 1, 2, 2, 2, 2, 6, 1, 2, 1, 14, -1, 5, 2, 2, 1, 5, 2, 3, 1, 6, 1, 8, 3, 6, 2, 3, 1, -1, 3, 18, 1, 2, 3, 2, 2, 3, 1, 2, 9, 3, 5, 2, 2, 96, 1, 3, -1, 5, 1, 2, 1, 2, 15, 14, 1, 44, 1, 3, -1
Offset: 1
Keywords
Examples
Let b(k) be the recursive sequence defined by the initial conditions b(0) = 1, b(1) = 16, and the recursive equation b(k) = 15*b(k-1) - b(k-2). a(15) = 2 because b(2) = 239 is the smallest prime in b(k). Let c(k) be the recursive sequence defined by the initial conditions c(0) = 1, c(1) = 18, and the recursive equation c(k) = 17*c(k-1) - c(k-2). a(17) = 3 because c(3) = 5167 is the smallest prime in c(k).
Links
- Hans Havermann, Table of n, a(n) for n = 1..946
- Hans Havermann, Table of n, a(n) for n = 1..10000
- C. K. Caldwell, Top Twenty page, Lehmer number
- Andrew N. W. Hone, et al., On a family of sequences related to Chebyshev polynomials, arXiv:1802.01793 [math.NT], 2018.
- Brad Klee, Proof for A269254, Sequence Fans Mailing List, October 2017.
- N. J. A. Sloane et al., Proof that a(110) = -1
- Wikipedia, Lehmer number.
Crossrefs
Programs
-
Magma
lst:=[]; for n in [1..85] do if n gt 2 and IsSquare(n+2) then Append(~lst, -1); else a:=n+1; c:=1; t:=1; if IsPrime(a) then Append(~lst, t); else repeat b:=n*a-c; c:=a; a:=b; t+:=1; until IsPrime(a); Append(~lst, t); end if; end if; end for; lst;
-
Mathematica
kmax = 100; a[1] = a[2] = 1; a[n_ /; IntegerQ[Sqrt[n+2]]] = -1; a[n_] := Module[{s}, s[0] = 1; s[1] = n+1; s[k_] := s[k] = n s[k-1] - s[k-2]; For[k=1, k <= kmax, k++, If[PrimeQ[s[k]], Return[k]]]; Print["For n = ", n, ", k = ", k, " exceeds the limit kmax = ", kmax]; -1]; Array[a, 110] (* Jean-François Alcover, Aug 05 2018 *)
-
PARI
allocatemem(2^30); default(primelimit,(2^31)+(2^30)); s(n,k) = if(0==k,1,if(1==k,(1+n),((n*s(n,k-1)) - s(n,k-2)))); A269254(n) = { my(k=1); if((n>2)&&issquare(2+n),-1,while(!isprime(s(n,k)),k++);(k)); }; \\ Antti Karttunen, Oct 20 2017
Formula
If n is prime then a(n-1) = 1.
Extensions
a(86)-a(94) from Antti Karttunen, Oct 20 2017
a(95)-a(109) appended by L. Edson Jeffery, Oct 22 2017
Comments