cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

A272441 Primes with a prime number of binary digits.

This page as a plain text file.
%I A272441 #32 Feb 03 2025 16:49:46
%S A272441 2,3,5,7,17,19,23,29,31,67,71,73,79,83,89,97,101,103,107,109,113,127,
%T A272441 1031,1033,1039,1049,1051,1061,1063,1069,1087,1091,1093,1097,1103,
%U A272441 1109,1117,1123,1129,1151,1153,1163,1171,1181,1187,1193,1201,1213,1217,1223
%N A272441 Primes with a prime number of binary digits.
%H A272441 Alois P. Heinz, <a href="/A272441/b272441.txt">Table of n, a(n) for n = 1..20000</a>
%e A272441 7 is a term since its binary representation has 3 bits, a prime.
%e A272441 67 is a term since its binary representation has 7 bits, a prime.
%t A272441 Select[Table[j, {j, 1, 1200}], (PrimeQ[#] && PrimeQ[Length@IntegerDigits[#, 2]]) &]
%t A272441 Select[Prime[Range[200]],PrimeQ[Length[IntegerDigits[#,2]]]&] (* _Harvey P. Dale_, Jun 04 2019 *)
%o A272441 (PARI) isok(n) = isprime(n) && isprime(#binary(n)); \\ _Michel Marcus_, Apr 30 2016
%o A272441 (PARI) forprime(d=2,13, forprime(p=2^(d-1),2^d, print1(p", "))) \\ _Charles R Greathouse IV_, May 01 2016
%o A272441 (Python)
%o A272441 from itertools import islice
%o A272441 from sympy import isprime, nextprime
%o A272441 def agen(): # generator of terms
%o A272441     d = 3
%o A272441     yield from [2, 3]
%o A272441     while True:
%o A272441         yield from (i for i in range(2**(d-1)+1, 2**d, 2) if isprime(i))
%o A272441         d = nextprime(d)
%o A272441 print(list(islice(agen(), 50))) # _Michael S. Branicky_, Dec 27 2023
%o A272441 (Python)
%o A272441 from sympy import primepi, primerange
%o A272441 def A272441(n):
%o A272441     def bisection(f,kmin=0,kmax=1):
%o A272441         while f(kmax) > kmax: kmax <<= 1
%o A272441         kmin = kmax >> 1
%o A272441         while kmax-kmin > 1:
%o A272441             kmid = kmax+kmin>>1
%o A272441             if f(kmid) <= kmid:
%o A272441                 kmax = kmid
%o A272441             else:
%o A272441                 kmin = kmid
%o A272441         return kmax
%o A272441     def f(x): return n+x-sum(primepi(min(x,(1<<i)-1))-primepi((1<<i-1)-1) for i in primerange(2,x.bit_length()+1))
%o A272441     return bisection(f,n,n) # _Chai Wah Wu_, Feb 03 2025
%Y A272441 Cf. A120533 (analogous in base 10).
%K A272441 nonn,base,easy
%O A272441 1,1
%A A272441 _Andres Cicuttin_, Apr 30 2016