login

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”).

A178993
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
4
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, 25, 23, 26, 30, 30, 31, 28, 32, 34, 34, 36, 36, 38, 38, 39, 41, 41, 43, 43, 43, 42, 45, 41, 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
OFFSET
1,2
COMMENTS
when k=n and 2^n+2^k-1 is prime then the prime is a Mersenne prime and n+1 is prime
EXAMPLE
2^1+2^1+1=5 prime as 2^1+2^1-1=3 Mersenne prime so k(1)=1
2^2+2^2-1=7 Mersenne prime so k(2)=2
2^3+2^3+1=17 prime so k(3)=3
2^4+2^4-1=31 Mersenne prime so k(4)=4
2^5+2^4-1=47 prime so k(5)=4
MATHEMATICA
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]
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 *)
CROSSREFS
Sequence in context: A066981 A130043 A089266 * A193768 A361784 A361318
KEYWORD
nonn
AUTHOR
Pierre CAMI, Jan 03 2011
STATUS
approved