%I #19 Dec 26 2022 17:16:31
%S 12,176,376,532,590,3015,4510,4676,7315,7526,7957,8855,12650,15555,
%T 17120,19437,20126,22265,25676,29330,30175,40755,48510,54626,78547,
%U 82017,91390,97410,101270,102051,102835,105205
%N Pentagonal numbers which are the arithmetic mean of two consecutive primes.
%C The n-th pentagonal number is (3*n^2 - n)/2 = n*(3*n - 1)/2.
%H K. D. Bajpai, <a href="/A234531/b234531.txt">Table of n, a(n) for n = 1..5535</a>
%e 376 is in the sequence because 376 = 16*(3*16 - 1)/2 = (373 + 379)/2, the arithmetic mean of two consecutive primes.
%e 532 is in the sequence because 532 = 19*(3*19 - 1)/2 = (523 + 541)/2, the arithmetic mean of two consecutive primes.
%p KD := proc() local a,b,d,g; a:= n*(3*n-1)/2; b:=prevprime(a); d:=nextprime(b); g:=(b+d)/2; if a=g then RETURN (a); fi; end: seq(KD(), n = 2..500);
%t Select[PolygonalNumber[5,Range[300]],!PrimeQ[#]&&#==(NextPrime[ #]+ NextPrime[ #,-1])/2&] (* _Harvey P. Dale_, Dec 26 2022 *)
%o (PARI) lista(nn) = for (n=1, nn, pn = n*(3*n-1)/2; if (pn > 2, precp = precprime(pn-1); if (pn == (precp + nextprime(precp+1))/2, print1(pn, ", ")))) \\ _Michel Marcus_, Dec 30 2013
%Y Cf. A000326 (pentagonal numbers: n * (3 * n - 1 ) / 2).
%Y Cf. A069495 (squares: arithmetic mean of two consecutive primes).
%Y Cf. A234240 (cubes: arithmetic mean of three consecutive primes).
%K nonn
%O 1,1
%A _K. D. Bajpai_, Dec 27 2013
%E Erroneous term 5 removed by _Michel Marcus_, Dec 30 2013