cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

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.

Original entry on oeis.org

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

Views

Author

Arkadiusz Wesolowski, Jul 09 2016

Keywords

Comments

The s(k) sequences can be viewed in A294099, where they appear as rows. - Peter Munn, Aug 31 2020
For n >= 3, a(n) is that positive integer k yielding the smallest prime of the form (x^y - 1/x^y)/(x - 1/x), where x = (sqrt(n+2) +- sqrt(n-2))/2 and y = 2*k + 1, or -1 if no such k exists.
Every positive term belongs to A005097.
When n=7, the sequence {s(k)} is A033890, which is Fibonacci(4i+2), and since x|y <=> F_x|F_y, and 2i+1|4i+2, A033890 is never prime, and so a(7)=-1. For the other -1 terms below 100, see the theorem below and the Klee link - N. J. A. Sloane, Oct 20 2017 and Oct 22 2017
Theorem (Brad Klee): For all n > 2, a(n^2 - 2) = -1. See Klee link for a proof. - L. Edson Jeffery, Oct 22 2017
Theorem (Based on work of Hans Havermann, L. Edson Jeffery, Brad Klee, Don Reble, Bob Selcoe, and N. J. A. Sloane) a(110) = -1. [For proof see link. - N. J. A. Sloane, Oct 23 2017]
From Bob Selcoe, Oct 24 2017, edited by N. J. A. Sloane, Oct 27 2017: (Start)
Suppose n = m^2 - 2, where m >= 3, and let j = m-2, with j >= 1.
For this value of n, the sequence s(k) satisfies s(k) = (c(k) + d(k))*(c(k) - d(k)), where c(0) = 1, d(0) = 0; and for k >= 1: c(k) = (j+2)*c(k-1) - d(k-1), and d(k) = c(k-1). So (as Brad Klee already proved) a(n) = -1 .
We have s(0) = 1 and s(1) = n+1 = j^2 + 4j + 3. In general, the coefficients of s(k) when expanded in powers of j are given by the (4k+2)-th row of A011973 (the triangle of coefficients of Fibonacci polynomials) in reverse order. For example, s(2) = j^4 + 8j^3 + 21j^2 + 20j + 5, s(3) = j^6 + 12j^5 + 55j^4 + 120j^3 + 126j^2 + 56j + 7, etc.
Perhaps the above comments could be generalized to apply to a(110) or to other n for which a(n) = -1?
(End)
For detailed theory, see [Hone]. - L. Edson Jeffery, Feb 09 2018

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).
		

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