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.

A269251 a(n) = smallest prime in the sequence s(k) = n*s(k-1) - s(k-2), with s(0) = 1, s(1) = n - 1 (or a(n) = -1 if no such prime exists).

Original entry on oeis.org

-1, -1, 2, 3, 19, 5, 41, 7, 71, 89, 109, 11, 2003, 13, 3121, 239, 271, 17, 729962708557509701, 19, 419, 461, 11593, 23, 599, 11356201, 701, 11546481261621528160662473705515857458665002781273993, 811, 29, 929
Offset: 1

Views

Author

Arkadiusz Wesolowski, Jul 09 2016

Keywords

Comments

For n >= 2, smallest prime of the form (x^y + 1/x^y)/(x + 1/x), where x = (sqrt(n+2) +- sqrt(n-2))/2 and y is an odd positive integer, or -1 if no such prime exists.
If a(34) > 0 then a(34) > 10^1000. - Robert Israel, Feb 06 2018
For detailed theory, see [Hone]. - L. Edson Jeffery, Feb 09 2018
Values of n where a(n) might need more than 1000 digits: 34, 52, 123, 254, 275, 285, 322, 371, 401, 413, 437, 460, 508, 518, 535, 540, 629, 643, 653, 691, 723, 724, 753, 797, 837, 843, 876, 881, 898, 913, 960, 970, 981, 986, 987, ... - Jean-François Alcover, Mar 01 2018

Crossrefs

Programs

  • Magma
    lst:=[]; for n in [1..31] do if n le 2 then Append(~lst, 0); else a:=1; c:=1; repeat b:=n*a-c; c:=a; a:=b; until IsPrime(a); Append(~lst, a); end if; end for; lst;
  • Maple
    f:= proc(n) local a,b,t;
    a:= 1; b:= n-1;
    do
      if isprime(b) then return b fi;
      t:= n*b-a;
      a:= b;
      b:= t;
    od
    end proc:
    f(1):= -1: f(2):= -1:
    map(f, [$1..33]); # Robert Israel, Feb 06 2018
  • Mathematica
    max = 10^1000; a[1] = a[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, s[k] <= max, k++, If[PrimeQ[s[k]], Return[s[k]]]]] /. Null -> -1; Table[a[n], {n, 1, 33}] (* Jean-François Alcover, Mar 01 2018 *)

Formula

If n is prime then a(n+1) = n.

Extensions

Changed the value for the exceptional case from 0 to -1 for consistency with other sequences. - N. J. A. Sloane, Jan 19 2018