login
A272441
Primes with a prime number of binary digits.
2
2, 3, 5, 7, 17, 19, 23, 29, 31, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 1031, 1033, 1039, 1049, 1051, 1061, 1063, 1069, 1087, 1091, 1093, 1097, 1103, 1109, 1117, 1123, 1129, 1151, 1153, 1163, 1171, 1181, 1187, 1193, 1201, 1213, 1217, 1223
OFFSET
1,1
LINKS
EXAMPLE
7 is a term since its binary representation has 3 bits, a prime.
67 is a term since its binary representation has 7 bits, a prime.
MATHEMATICA
Select[Table[j, {j, 1, 1200}], (PrimeQ[#] && PrimeQ[Length@IntegerDigits[#, 2]]) &]
Select[Prime[Range[200]], PrimeQ[Length[IntegerDigits[#, 2]]]&] (* Harvey P. Dale, Jun 04 2019 *)
PROG
(PARI) isok(n) = isprime(n) && isprime(#binary(n)); \\ Michel Marcus, Apr 30 2016
(PARI) forprime(d=2, 13, forprime(p=2^(d-1), 2^d, print1(p", "))) \\ Charles R Greathouse IV, May 01 2016
(Python)
from itertools import islice
from sympy import isprime, nextprime
def agen(): # generator of terms
d = 3
yield from [2, 3]
while True:
yield from (i for i in range(2**(d-1)+1, 2**d, 2) if isprime(i))
d = nextprime(d)
print(list(islice(agen(), 50))) # Michael S. Branicky, Dec 27 2023
CROSSREFS
Cf. A120533 (analogous in base 10).
Sequence in context: A360781 A042994 A129692 * A155471 A158015 A042995
KEYWORD
nonn,base,easy
AUTHOR
Andres Cicuttin, Apr 30 2016
STATUS
approved