%I #33 Sep 08 2022 08:45:54
%S 2,3,5,6,9,14,15,21,24,26,30,38,39,41,48,53,54,78,80,81,87,89,92,104,
%T 116,117,119,121,122,125,126,146,149,150,153,156,158,164,165,170,171,
%U 185,186,194,206,210,218,245,248,252,255,258,270,281,285,290,296,297
%N Numbers k such that the k-th triangular number is prime or the arithmetic mean of 2 successive primes.
%H Charles R Greathouse IV, <a href="/A181902/b181902.txt">Table of n, a(n) for n = 1..10000</a>
%e 2 is a term because 2*(2+1)/2 = 3 is prime,
%e 3 is a term because 3*(3+1)/2 = (5+7)/2,
%e 5 is a term because 5*(5+1)/2 = (13+17)/2.
%t a = {2}; For[n = 1, n < 320, n++, t = n*(n + 1)/2;
%t If[t == (NextPrime[t] + NextPrime[t, -1])/2, AppendTo[a, n],
%t 1]]; Print[a]; (* _David Scambler_, Apr 02 2012 *)
%o (PARI) is(n)=n*=(n+1)/2;n>1&&2*n==nextprime(n)+precprime(n) \\ _Charles R Greathouse IV_, Apr 04 2012
%o (Magma) [2] cat [n: n in [3..320] | 2*t eq PreviousPrime(t)+NextPrime(t) where t is n*(n+1) div 2]; // _Bruno Berselli_, Apr 04 2012
%Y Cf. A000217, A001043.
%K nonn
%O 1,1
%A _Juri-Stepan Gerasimov_, Mar 31 2012
%E Terms corrected by _Gerasimov Sergey_, _R. J. Mathar_, and _Charles R Greathouse IV_, Apr 04 2012