Year-end appeal: Please make a donation to the OEIS Foundation to support ongoing development and maintenance of the OEIS. We are now in our 61st year, we have over 378,000 sequences, and we’ve reached 11,000 citations (which often say “discovered thanks to the OEIS”).
%I #12 Mar 05 2019 14:32:51
%S 1,2,3,4,4,6,7,7,8,8,6,12,12,13,15,16,16,18,18,19,17,16,20,21,18,21,
%T 25,23,26,30,30,31,28,32,34,34,36,36,38,38,39,41,41,43,43,43,42,45,41,
%U 48,46,48,50,45,52,55,55,54,48,60,56,61,56,60,64,64,66,66,61,67,66,66,68,72,66,67,76,76,72,73
%N Greatest k <= n such that 2^n+2^k+1 or 2^n+2^k-1 or 2^n-2^k+1 or 2^n-2^k-1 is prime
%C when k=n and 2^n+2^k-1 is prime then the prime is a Mersenne prime and n+1 is prime
%H Pierre CAMI, <a href="/A178993/b178993.txt">Table of n, a(n) for n = 1..5017</a>
%e 2^1+2^1+1=5 prime as 2^1+2^1-1=3 Mersenne prime so k(1)=1
%e 2^2+2^2-1=7 Mersenne prime so k(2)=2
%e 2^3+2^3+1=17 prime so k(3)=3
%e 2^4+2^4-1=31 Mersenne prime so k(4)=4
%e 2^5+2^4-1=47 prime so k(5)=4
%t f[n_] := Block[{k = n}, While[ !PrimeQ[2^n + 2^k + 1] && !PrimeQ[2^n + 2^k - 1] && !PrimeQ[2^n - 2^k + 1] && !PrimeQ[2^n - 2^k - 1], k--]; k]; Array[f, 80]
%t gk[n_]:=Module[{c=2^n,k=n},While[NoneTrue[{c+2^k+1,c+2^k-1,c-2^k+1,c-2^k- 1},PrimeQ],k--];k]; Array[gk,80] (* Requires Mathematica version 10 or later *) (* _Harvey P. Dale_, Mar 05 2019 *)
%K nonn
%O 1,2
%A _Pierre CAMI_, Jan 03 2011