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.

A214344 Number of 1's in the first 10^n binary digits in the stream of prime numbers in base 2.

This page as a plain text file.
%I A214344 #25 Jul 03 2022 16:23:32
%S A214344 1,8,69,593,5723,56090,541794,5369528,53803123,527428642,5249946808,
%T A214344 52800311682
%N A214344 Number of 1's in the first 10^n binary digits in the stream of prime numbers in base 2.
%C A214344 Consider the stream (concatenation) of binary digits of primes in the MSB-first order featured in A191232. a(n) is the total count of 1's in the first 10^n of zeros and ones in this stream.
%C A214344 The complementary count of 0's is 10^n - a(n) = 0, 2, 31, 407, 4277, 43910, 458206, ... - _R. J. Mathar_, Jul 16 2012
%p A214344 A214344 := proc()
%p A214344     local stre,len,ct,p ;
%p A214344     stre := [] ;
%p A214344     len := 2 ;
%p A214344     ct := 1 ;
%p A214344     p := 2 ;
%p A214344     while true do
%p A214344         if nops(stre) = 0 then
%p A214344             p := nextprime(p) ;
%p A214344             stre := convert(p,base,2) ;
%p A214344         end if;
%p A214344         if op(-1,stre) = 1 then
%p A214344             ct := ct+ 1;
%p A214344         end if;
%p A214344         stre := subsop(-1=NULL,stre) ;
%p A214344         len := len+1 ;
%p A214344         if ilog10(len-1) <> ilog10(len) then
%p A214344             print(ct) ;
%p A214344         end if;
%p A214344     end do:
%p A214344 end proc: # _R. J. Mathar_, Jul 14 2012
%t A214344 pow = 1; sum1 = 0; sum2 = 0; p = 2;seq={}; k = 0; Do[d = IntegerDigits[p, 2]; sum1 += Count[d, 1]; sum2 += Length[d]; k++; If[sum2 >= pow, del = sum2 - pow; term = sum1 - Count[d[[-del ;; -1]], 1];   AppendTo[seq, term]; pow *= 10]; p = NextPrime[p], {10^4}]; seq (* _Amiram Eldar_, May 10 2019 *)
%o A214344 (Python)
%o A214344 from sympy import nextprime
%o A214344 from itertools import islice
%o A214344 def bgen(p=2):
%o A214344     while True: yield from (int(b) for b in bin(p)[2:]); p = nextprime(p)
%o A214344 def a(n): return sum(islice(bgen(), 10**n))
%o A214344 print([a(n) for n in range(7)]) # _Michael S. Branicky_, Jul 03 2022
%Y A214344 Cf. A095375.
%K A214344 nonn,more,base
%O A214344 0,2
%A A214344 _Tjandra Satria Gunawan_, Jul 13 2012
%E A214344 a(9)-a(11) from _Amiram Eldar_, May 10 2019