%I #22 Sep 08 2022 08:46:12
%S 7,13,19,31,37,61,67,109,127,139,157,181,193,199,211,307,313,337,379,
%T 397,409,487,499,541,571,577,631,691,751,769,787,811,829,877,919,937,
%U 991,1009,1021,1039,1117,1201,1291,1297,1327,1381,1399,1459,1471,1531,1567
%N Primes p such that p+2 divides p^p+2.
%C All the terms in this sequence are congruent to 1 mod 3.
%C Primes p such that 2^p == 2 (mod p+2). Includes A091180. - _Robert Israel_, Apr 14 2015
%H K. D. Bajpai, <a href="/A257002/b257002.txt">Table of n, a(n) for n = 1..5700</a>
%e a(1) = 7 is prime; 7+2 = 9 divides 7^7 + 2 = 823545.
%e a(2) = 13 is prime; 13+2 = 15 divides 13^13 + 2 = 302875106592255.
%p select(t -> isprime(t) and (2 &^t - 2) mod (t+2) = 0, [seq(6*i+1,i=1..10^4)]); # _Robert Israel_, Apr 14 2015
%t Select[Prime[Range[3000]], Mod[#^# + 2, # + 2] == 0 &]
%t Select[Prime[Range[500]],PowerMod[#,#,#+2]==#&] (* _Harvey P. Dale_, May 19 2017 *)
%o (PARI) forprime(p=2,1000, if(Mod(p^p+2,p+2)==0, print1(p, ", ")));
%o (Python)
%o from sympy import prime
%o A257002_list = [p for p in (prime(n) for n in range(1,10**4)) if pow(p, p, p+2) == p] # _Chai Wah Wu_, Apr 14 2015
%o (Magma) [ p: p in PrimesUpTo(1600) | (p^p+2) mod (p+2) eq 0 ]; // _Vincenzo Librandi_, Apr 15 2015
%Y Cf. A000040, A091180, A213382.
%K nonn
%O 1,1
%A _K. D. Bajpai_, Apr 14 2015