%I #21 Dec 23 2024 14:53:45
%S 0,2,3,4,5,7,167
%N Numbers n such that (1 + n)^n + (-n)^n is prime.
%C The next term, if it exists, is > 10000. - _Hugo Pfoertner_, Jan 06 2020
%C The associated primes are: 13, 37, 881, 4651, 1273609, ...
%C From _Robert Israel_, Apr 28 2017: (Start)
%C All terms other than 0 are primes or powers of 2.
%C Heuristically, this sequence might be expected to be finite. (End)
%H J. S. Gerasimov, <a href="https://web.archive.org/web/*/http://list.seqfan.eu/oldermail/seqfan/2014-August/013480.html">x^(y + 1) - y^x</a>, SeqFan list, Aug 18 2014.
%e 4 is in this sequence because (1 + 4)^4 + (-4)^4 = 881 is prime.
%p N:= 1000: # to get all terms <= N
%p cands:= select(isprime, {seq(i,i=3..N,2)}) union {0, seq(2^k, k=1..ilog2(N))}:
%p select(n -> isprime((1+n)^n + (-n)^n), cands); # _Robert Israel_, Apr 28 2017
%o (Magma) [n: n in [0..170]| IsPrime((n+1)^n + (-n)^n)];
%o (PARI) is(n)=ispseudoprime((n+1)^n+(-n)^n) \\ _Charles R Greathouse IV_, Apr 28 2017
%Y Supersequence of A098463.
%Y Cf. A243100, A285886, A285887.
%K nonn,more
%O 1,2
%A _Juri-Stepan Gerasimov_, Apr 27 2017