login
Define k(0) = 2 and k(m) = m^2-k(m-1) for m >= 1. This is a list of those terms k(m) for which k(m)+1 and k(m)-1 are both in A008578 (primes including 1).
2

%I #19 Jul 18 2022 19:28:51

%S 2,4,12,138,822,2082,3918,21738,39342,62130,70878,106032,117372,

%T 129288,135462,182712,512580,524802,575130,682698,769422,799482,

%U 893118,1008912,1026030,1043292,1828830,2368578,2447580,3247428,3278082,3465030,4022868,4056978

%N Define k(0) = 2 and k(m) = m^2-k(m-1) for m >= 1. This is a list of those terms k(m) for which k(m)+1 and k(m)-1 are both in A008578 (primes including 1).

%F k(n) = n*(n+1)/2+2*(-1)^n. - _Peter Luschny_, Jul 14 2022

%p a := proc(n) local k; k := n*(n - 1)/2 - 2*(-1)^n:

%p if k = 2 or isprime(k - 1) and isprime(k + 1) then k else NULL fi end:

%p seq(a(n), n = 1..1000); # _Peter Luschny_, Jul 14 2022

%t k=2;lst={k};Do[k=n^2-k;If[PrimeQ[k-1]&&PrimeQ[k+1],AppendTo[lst,k]],{n,8!}];lst

%o (PARI) a154734(upto,k0=2) = {my(k=k0); print1(k,", "); for(n=1, oo, my(kk=n^2-k);if(isprime(k-1) && isprime(k+1), print1(k,", ")); k=kk; if(k>upto, break))};

%o a154734(5000000) \\ _Hugo Pfoertner_, Jul 14 2022

%Y Cf. A008578, A154736.

%K nonn

%O 1,1

%A _Vladimir Joseph Stephan Orlovsky_, Jan 14 2009

%E Better name from _Pontus von Brömssen_, Jul 14 2022