OFFSET
3,2
COMMENTS
Previous name was: "Useful safe primes: a(n) = least nonnegative integer k such that 2^n - k is prime and (2^n-k-1)/2 is also prime". The resulting sequence of 2^n-k terms: 7, 11, 23, 59, 107, ..., are thus the largest safe primes smaller than 2^n (A243916), a subsequence of A005385. - Michel Marcus, Jan 08 2014
LINKS
Mark Andreas, Table of n, a(n) for n = 3..5120 (first 3070 terms from Artsiom Palkounikau)
PROG
(PARI) a(n) = {my(k=0); until (isprime(2^n-k) && isprime((2^n-k-1)/2), k++); return (k); } \\ Michel Marcus, Jun 29 2013
(Python)
from sympy import isprime
def a(n):
k=0
while True:
k+=1
if isprime(2**n - k) and isprime((2**n - k - 1)//2): return k
print([a(i) for i in range(3, 21)]) # Indranil Ghosh, Jun 12 2017, after PARI code by Michel Marcus
CROSSREFS
KEYWORD
nonn
AUTHOR
Warren D. Smith, Nov 23 2000
STATUS
approved