login
Exponents n such that 2^n - previous_prime(2^n) = next_prime(2^n) - 2^n.
3

%I #24 Aug 09 2022 02:22:49

%S 2,6,12,76,181,1099,1820,9229

%N Exponents n such that 2^n - previous_prime(2^n) = next_prime(2^n) - 2^n.

%C The differences next_prime(2^n) - 2^n are respectively: 1, 3, 3, 15, 165, 1035, 663, 2211.

%C If it exists, a(9) > 10000. - _Hugo Pfoertner_, Feb 06 2021

%F A340707(a(n)) = 0. - _Hugo Pfoertner_, Feb 06 2021

%e 2^6 = 64, next prime = 67, previous prime = 61, 67-64 = 64-61 = 3, hence 6 is in the sequence.

%t Reap[Do[m = 2^n; p = NextPrime[m, -1]; q = NextPrime[m]; If[p + q == 2*m, Print[n]; Sow[n]], {n, 2, 10^4}]][[2, 1]]

%o (PARI) isok(n) = my(p=2^n); p-precprime(p-1) == nextprime(p+1) - p; \\ _Michel Marcus_, Oct 02 2019

%o (PARI) for(n=2,1100,my(p2=2^n,pn=nextprime(p2),pp=p2-pn+p2);if(ispseudoprime(pp),if(precprime(p2)==pp,print1(n,", ")))) \\ _Hugo Pfoertner_, Feb 06 2021

%o (Python)

%o from itertools import count, islice

%o from sympy import isprime, nextprime

%o def A226178_gen(): # generator of terms

%o return filter(lambda n:isprime(r:=((k:=1<<n)<<1)-(m:=nextprime(k))) and nextprime(r)==m, count(1))

%o A226178_list = list(islice(A226178_gen(),5)) # _Chai Wah Wu_, Aug 08 2022

%Y Cf. A000079, A014210, A014234, A117387, A145025.

%Y Cf. A013597, A013603, A340707.

%K nonn,hard,more

%O 1,1

%A _Jean-François Alcover_, May 30 2013

%E Offset 1 from _Michel Marcus_, Oct 02 2019

%E a(8) from _Hugo Pfoertner_, Feb 05 2021