login
Primes whose gaps to both neighbor primes are triangular numbers.
5

%I #18 May 14 2022 11:23:40

%S 53,157,173,251,257,263,337,373,547,557,563,577,587,593,607,653,733,

%T 947,977,1039,1103,1123,1181,1187,1223,1367,1627,1747,1753,1907,2017,

%U 2063,2287,2417,2677,2719,2897,2903,2963,3307,3313,3517,3547,3637,3733,4013,4211

%N Primes whose gaps to both neighbor primes are triangular numbers.

%H Alois P. Heinz, <a href="/A353136/b353136.txt">Table of n, a(n) for n = 1..10000</a>

%e Prime 251 is a term, the gap to the previous prime 241 is 10 and the gap to the next prime 257 is 6 and both gaps are triangular numbers.

%p t:= proc(n) option remember; issqr(8*n+1) end:

%p q:= n-> isprime(n) and andmap(t, [n-prevprime(n), nextprime(n)-n]):

%p select(q, [$3..5000])[];

%t t[n_] := IntegerQ@Sqrt[8n+1];

%t q[n_] := PrimeQ[n] && t[n-NextPrime[n, -1]] && t[NextPrime[n]-n];

%t Select[Range[3, 5000], q] (* _Jean-François Alcover_, May 14 2022, after _Alois P. Heinz_ *)

%Y Cf. A000040, A000217, A014494, A353088, A353135, A353137.

%K nonn

%O 1,1

%A _Alois P. Heinz_, Apr 25 2022