login

Year-end appeal: Please make a donation to the OEIS Foundation to support ongoing development and maintenance of the OEIS. We are now in our 61st year, we have over 378,000 sequences, and we’ve reached 11,000 citations (which often say “discovered thanks to the OEIS”).

A154734
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
2, 4, 12, 138, 822, 2082, 3918, 21738, 39342, 62130, 70878, 106032, 117372, 129288, 135462, 182712, 512580, 524802, 575130, 682698, 769422, 799482, 893118, 1008912, 1026030, 1043292, 1828830, 2368578, 2447580, 3247428, 3278082, 3465030, 4022868, 4056978
OFFSET
1,1
FORMULA
k(n) = n*(n+1)/2+2*(-1)^n. - Peter Luschny, Jul 14 2022
MAPLE
a := proc(n) local k; k := n*(n - 1)/2 - 2*(-1)^n:
if k = 2 or isprime(k - 1) and isprime(k + 1) then k else NULL fi end:
seq(a(n), n = 1..1000); # Peter Luschny, Jul 14 2022
MATHEMATICA
k=2; lst={k}; Do[k=n^2-k; If[PrimeQ[k-1]&&PrimeQ[k+1], AppendTo[lst, k]], {n, 8!}]; lst
PROG
(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))};
a154734(5000000) \\ Hugo Pfoertner, Jul 14 2022
CROSSREFS
Sequence in context: A154882 A062000 A053040 * A291827 A287059 A059085
KEYWORD
nonn
AUTHOR
EXTENSIONS
Better name from Pontus von Brömssen, Jul 14 2022
STATUS
approved