OFFSET
0,1
COMMENTS
FORMULA
a(n) = min {p - n, q + n - 1}, where p = 2^r + 2n - 1 and q = 2^s - 2n + 1 are the smallest primes of the respective form.
EXAMPLE
0 + 1 = 1 is not of the required form, but 0 + 1 + 2 = 3 is, so a(0) = 2.
For n = 1, n + 2 = 3 is of the required form, hence a(1) = 2.
For n = 2, n + 3 = 5 is of the required form, hence a(2) = 3.
For n = 3, n + 4 = 7 is of the required form, hence a(3) = 4.
For n = 4, 4 + 5 = 9 and 4 + 5 + 6 = 15 are not of the required form, but 4 + 5 + 6 + 7 = 22 = 11*2 is, hence a(4) = 7.
PROG
(PARI) apply( A332106(n)={my(r=1, p=2*(r+n)-1, s=2<<exponent(n+!n), q=2*(s-n)+1); while(n, if(p-n<q+n-1, isprime(p)&&return(p-n); p+=r*=2, isprime(q)&&return(q+n-1); q+=s*=2)); 2} , [0..77])
CROSSREFS
KEYWORD
nonn
AUTHOR
M. F. Hasler, Aug 29 2020
STATUS
approved