OFFSET
0,1
COMMENTS
EXAMPLE
4 is in the sequence because (prevprime(2^4) AND nextprime(2^4)) = 13 AND 17 = 1.
MATHEMATICA
ba1Q[n_]:=Module[{c=2^n}, BitAnd[NextPrime[c], NextPrime[c, -1]]==1]; Select[ Range[ 450], ba1Q] (* Harvey P. Dale, Dec 25 2012 *)
PROG
(Java)
import java.math.BigInteger;
public class A214415 {
public static void main (String[] args) {
BigInteger b1 = BigInteger.valueOf(1);
BigInteger b2 = BigInteger.valueOf(2);
for (int n=2; ; n++) {
BigInteger pwr = b1.shiftLeft(n);
BigInteger pm = pwr.subtract(b1);
BigInteger pp = pwr.add(b1);
while (true) {
if (pm.isProbablePrime(2)) {
if (pm.isProbablePrime(80)) break;
}
pm = pm.subtract(b2);
}
while (true) {
if (pp.isProbablePrime(2)) {
if (pp.isProbablePrime(80)) break;
}
pp = pp.add(b2);
}
if (pm.and(pp).equals(b1)) {
System.out.printf("%d, ", n);
}
}
}
}
(PARI)
{ for (n=2, 1000, N = 2^n;
p1 = precprime(N-1);
p2 = nextprime(N+1);
ba = bitand(p1, p2);
if ( bitand( ba, ba-1 ) == 0, print1(n, ", "));
); }
/* Joerg Arndt, Aug 16 2012 */
(Python)
from itertools import islice
from sympy import prevprime, nextprime
def A214415_gen(): # generator of terms
n, m = 2, 4
while True:
if prevprime(m)&nextprime(m) == 1:
yield n
n += 1
m *= 2
CROSSREFS
KEYWORD
nonn,base
AUTHOR
Alex Ratushnyak, Aug 07 2012
STATUS
approved