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.

Showing 1-10 of 11 results. Next

A168161 Primes p which are equal to the sum of the binary digits in all primes <= p.

Original entry on oeis.org

3, 5, 11, 19, 23, 47, 61
Offset: 1

Views

Author

M. F. Hasler, Nov 22 2009

Keywords

Comments

A subsequence of A168162.

Crossrefs

Programs

  • Mathematica
    sbdQ[n_]:=Total[Flatten[IntegerDigits[#,2]&/@Prime[Range[PrimePi[ n]]]]] == n; Select[Prime[Range[20]],sbdQ] (* Harvey P. Dale, Feb 04 2015 *)
  • PARI
    s=0; forprime(p=1, 9999, if(p==s+=norml2(binary(p)), print1(p, ", ")))

Formula

A168161 = { prime p | p=A095375(pi(p)) }, where pi(n) = A000720(n).

Extensions

Cross reference added by Harvey P. Dale, Mar 26 2013

A095376 Values of k such that the total number of 1's in the binary expansions of the first k integers is a multiple of k.

Original entry on oeis.org

1, 2, 14, 62, 65, 77, 254, 322, 323, 327, 331, 332, 1022, 1281, 1341, 1348, 1349, 1350, 1352, 1353, 1354, 4094, 16382, 21505, 21757, 21762, 21820, 65534, 87299, 87355, 262142, 348161, 349181, 1048574, 1397762, 1398012, 1398020, 1398074, 4194302
Offset: 1

Views

Author

Labos Elemer, Jun 07 2004

Keywords

Comments

All numbers of the form 4^k-2, with k>0, appear in this sequence. - Paul Tek, Sep 24 2013

Examples

			k=14: {1, 10, 11, 10, 101, 110, 111, 1000, 1001, 1010, 1011, 1100, 1101, 1110} includes 28 1's so A000788(14)/14 = 2 is an integer, thus 14 is here.
		

Crossrefs

Programs

  • Mathematica
    lib[x_] := Count[IntegerDigits[x, 2], 1]; {s=0, ta=Table[0, {100}], tb=Table[0, {100}], u=1}; Do[s=s+lib[n]; w=n; If[IntegerQ[s/n], Print[{n, s/n}]; ta[[u]]=n; tb[[u]]=s/n; u=u+1], {n, 100000}]

Formula

Integer solutions to {A000788(x)/x is an integer}.

A328659 Partial sums of A035100: number of binary digits of the primes.

Original entry on oeis.org

0, 2, 4, 7, 10, 14, 18, 23, 28, 33, 38, 43, 49, 55, 61, 67, 73, 79, 85, 92, 99, 106, 113, 120, 127, 134, 141, 148, 155, 162, 169, 176, 184, 192, 200, 208, 216, 224, 232, 240, 248, 256, 264, 272, 280, 288, 296, 304, 312, 320, 328, 336, 344, 352, 360, 369, 378, 387, 396, 405, 414, 423, 432
Offset: 0

Views

Author

M. F. Hasler, Oct 25 2019

Keywords

Comments

Useful to express the binary Copeland-Erdős constant, cf. formula.
Plotting a(n) against prime(n) might be a good tool for introducing students of mathematics, particularly those who are familiar with the use of binary representation, to the way the density of prime numbers decreases with increasing size. In essence, the graph of a(n) against prime(n) is approximately linear, and this becomes more obvious if we plot a(n)/prime(n): see the relevant plot in the links. - Peter Munn, Mar 03 2024

Examples

			Primes written in binary (A004676) read: 10, 11, 101, 111, 1011, 1101, 10001, ...
The length of the concatenation of the first n = 0, 1, 2, 3, .... terms is
  0, 2, 4, 7, 10, 14, 18, 23, ...: this sequence.
		

Crossrefs

Cf. A004676 (primes in binary), A035100 (their number of digits), A066747 & A191232: decimals and bits of the binary Copeland-Erdős constant.

Programs

  • Maple
    a := n -> add(ilog2(ithprime(k)), k=1..n) + n:
    seq(a(n), n=0..62); # Peter Luschny, Oct 26 2019
  • Mathematica
    Join[{0}, Accumulate[BitLength[Prime[Range[100]]]]] (* Paolo Xausa, Mar 20 2024 *)
  • PARI
    s=0; A328659=vector(50,n,s+=logint(prime(n),2)+1)
    
  • Python
    from sympy import prime, primerange as primes
    from itertools import accumulate
    def f(n): return len(bin(n)[2:])
    def aupton(nn): return [0]+list(accumulate(map(f, primes(2, prime(nn)+1))))
    print(aupton(62)) # Michael S. Branicky, Jun 26 2021

Formula

a(n) = n + Sum_{k=1..n} floor(log_2(prime(k))).
A066747 = Sum_{n >= 1} prime(n)/2^a(n), the binary Copeland-Erdős constant.
a(n) = a(n-1) + A035100(n), n >= 1.
a(n) = A095375(n) + A345867(n) for n >= 1. - Alois P. Heinz, Jun 28 2021

A168157 Number of 0's in the matrix whose lines are the binary expansion of the first n primes.

Original entry on oeis.org

1, 1, 4, 4, 9, 10, 19, 21, 22, 23, 23, 37, 40, 42, 43, 45, 46, 47, 69, 72, 76, 78, 81, 84, 88, 91, 93, 95, 97, 100, 100, 136, 141, 145, 149, 152, 155, 159, 162, 165, 168, 171, 172, 177, 181, 184, 187, 188, 191, 194, 197, 198, 201, 202, 263, 268, 273, 277, 282, 287
Offset: 1

Views

Author

M. F. Hasler, Nov 21 2009

Keywords

Comments

The matrix is to be taken of minimal size, i.e., have n lines and the number of columns needed to write the n-th prime in the last line, A035100(n). Otherwise said, there is no zero column except for n=1 (prime(1) = 2 = 10[2] in binary).
The number of zeros in the last line of the matrix is given by A035103(n).
One has a(n)=a(n-1) iff n = A059305(k) for some k, i.e. prime(n) is a Mersenne prime A000668(k) = A000225(A000043(k)).
If prime(n)=2^2^k+1 is a Fermat prime (A019434), n>2, then one has a(n)=a(n-1)+n-1+2^k-1.
More generally, the "big jumps" a(n+1) > a(n)+n happen whenever a column is added, i.e. when prime(n) = A014234(k) <=> prime(n+1) = A104080(k) for some k,n>1.

Examples

			a(4)=4 is the number of zeros in the matrix [010] /* = 2 in binary */ [011] /* = 3 in binary */ [101] /* = 5 in binary */ [111] /* = 7 in binary */
		

Programs

  • PARI
    A168157(n)=n*#binary(prime(n))-sum(i=1,n,norml2(binary(prime(i))))

Formula

a(n)=n*A035100(n)-A095375(n).

A168162 Numbers n which do not exceed the sum of the binary digits in all primes <= n.

Original entry on oeis.org

3, 5, 7, 8, 11, 13, 14, 19, 23, 31, 32, 47, 61
Offset: 1

Views

Author

M. F. Hasler, Nov 22 2009

Keywords

Comments

The sequence A168161 is a subsequence of the primes in this sequence.

Examples

			There is no prime <= 1 and 2 has only nonzero binary digit, therefore these numbers are not in the sequence.
However, a(1)=3 has two binary digits, so the total number of these equal 3.
Then, 4 is larger than this, but the prime p=5 again adds 2 nonzero binary digits adding to a total of 5=a(2).
Then 6 is larger than this, but the prime p=7 adds 3 more nonzero bits for a total of 8, such that a(3)=7 and a(4)=8 don't exceed this.
		

Programs

  • PARI
    s=0; for(n=1,9999, isprime(n) && s+=norml2(binary(n)); n<=s & print1(n", "))

Formula

A168162 = { n | n <= A095375(pi(n)) }, where pi(n) = A000720(n).

A345867 Total number of 0's in the binary expansions of the first n primes.

Original entry on oeis.org

1, 1, 2, 2, 3, 4, 7, 9, 10, 11, 11, 14, 17, 19, 20, 22, 23, 24, 28, 31, 35, 37, 40, 43, 47, 50, 52, 54, 56, 59, 59, 64, 69, 73, 77, 80, 83, 87, 90, 93, 96, 99, 100, 105, 109, 112, 115, 116, 119, 122, 125, 126, 129, 130, 137, 142, 147, 151, 156, 161, 165, 170
Offset: 1

Views

Author

Alois P. Heinz, Jun 26 2021

Keywords

Examples

			a(3) = 2: 2 = 10_2, 3 = 11_2, 5 = 101_2, so there are two 0's in the binary expansions of the first three primes.
		

Crossrefs

Partial sums of A035103.

Programs

  • Maple
    a:= proc(n) option remember; `if`(n=0, 0, a(n-1)
          +add(1-i, i=Bits[Split](ithprime(n))))
        end:
    seq(a(n), n=1..100);
  • Mathematica
    Accumulate[DigitCount[Prime[Range[100]], 2, 0]] (* Paolo Xausa, Feb 26 2024 *)
  • Python
    from sympy import prime, primerange
    from itertools import accumulate
    def f(n): return (bin(n)[2:]).count('0')
    def aupton(nn): return list(accumulate(map(f, primerange(2, prime(nn)+1))))
    print(aupton(62)) # Michael S. Branicky, Jun 26 2021

Formula

a(n) = Sum_{i=1..n} A035103(i).
a(n) = a(n-1) for n in { A059305 }.
a(n) = A328659(n) - A095375(n).

A168154 Numbers n such that the sum of binary digits in prime(1), ..., prime(n) is prime.

Original entry on oeis.org

2, 3, 5, 8, 9, 15, 18, 21, 28, 34, 35, 45, 51, 53, 68, 77, 84, 86, 87, 90, 92, 102, 113, 116, 119, 121, 130, 131, 137, 149, 164, 174, 178, 192, 205, 210, 220, 221, 238, 240, 241, 250, 255, 275, 315, 318, 324, 344, 345, 363, 369, 375, 381, 386, 396, 397, 398, 404
Offset: 1

Views

Author

M. F. Hasler, Nov 20 2009

Keywords

Comments

Indices of primes in A095375.

Crossrefs

Cf. A168153.

Programs

  • Mathematica
    Module[{nn=500,prs},prs=Table[IntegerDigits[p,2],{p,Prime[Range[nn]]}];Select[Range[nn],PrimeQ[Total[Flatten[Take[prs,#]]]]&]] (* Harvey P. Dale, Aug 28 2021 *)
  • PARI
    s=0; for(n=1,999, isprime(s+=norml2(binary(prime(n)))) & print1(n", "))
    is_A168154(n)=isprime(A095375(n))
    
  • PARI
    s=n=0;forprime(p=2,1e9,n++;if(isprime(s+=hammingweight(p)), print1(n", "))) \\ Charles R Greathouse IV, Mar 29 2013

Extensions

Terms corrected by Charles R Greathouse IV, Mar 29 2013

A168155 Sum of binary digits of all primes < 2^n, i.e., with at most n binary digits.

Original entry on oeis.org

0, 3, 8, 14, 32, 61, 117, 230, 470, 922, 1807, 3597, 7071, 14022, 27693, 54876, 109077, 216301, 430183, 854696, 1700412, 3382868, 6733230, 13404811, 26704639, 53204936, 106034897, 211377718, 421466683, 840573072, 1676670824, 3345012214, 6674425203, 13319553281
Offset: 1

Views

Author

M. F. Hasler, Nov 20 2009

Keywords

Comments

Partial sums of A168156.

Examples

			No prime can be written with only 1 binary digit, thus a(1)=0.
The primes that can be written with 2 binary digits are 2 = 10[2] and 3 = 11[2], they have 3 nonzero bits, so a(2)=3.
Primes with 3 binary digits are 5 = 101[2] and 7 = 111[3]. They add 5 more nonzero bits to yield a(3) = a(2)+5 = 8.
		

Crossrefs

Cf. A168153.

Programs

  • PARI
    s=0; L=p=2; while( L*=2, print1(s", "); until( L
    				

Formula

a(n) = A095375( pi( 2^n-1 )), where pi = A000720.

Extensions

a(25)-a(32) from Donovan Johnson, Jul 28 2010
a(33) from Chai Wah Wu, Apr 06 2020
a(34) from Chai Wah Wu, Apr 07 2020

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

Original entry on oeis.org

1, 8, 69, 593, 5723, 56090, 541794, 5369528, 53803123, 527428642, 5249946808, 52800311682
Offset: 0

Views

Author

Tjandra Satria Gunawan, Jul 13 2012

Keywords

Comments

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.
The complementary count of 0's is 10^n - a(n) = 0, 2, 31, 407, 4277, 43910, 458206, ... - R. J. Mathar, Jul 16 2012

Crossrefs

Cf. A095375.

Programs

  • Maple
    A214344 := proc()
        local stre,len,ct,p ;
        stre := [] ;
        len := 2 ;
        ct := 1 ;
        p := 2 ;
        while true do
            if nops(stre) = 0 then
                p := nextprime(p) ;
                stre := convert(p,base,2) ;
            end if;
            if op(-1,stre) = 1 then
                ct := ct+ 1;
            end if;
            stre := subsop(-1=NULL,stre) ;
            len := len+1 ;
            if ilog10(len-1) <> ilog10(len) then
                print(ct) ;
            end if;
        end do:
    end proc: # R. J. Mathar, Jul 14 2012
  • Mathematica
    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 *)
  • Python
    from sympy import nextprime
    from itertools import islice
    def bgen(p=2):
        while True: yield from (int(b) for b in bin(p)[2:]); p = nextprime(p)
    def a(n): return sum(islice(bgen(), 10**n))
    print([a(n) for n in range(7)]) # Michael S. Branicky, Jul 03 2022

Extensions

a(9)-a(11) from Amiram Eldar, May 10 2019

A308430 Number of 0's minus number of 1's among the edge truncated binary representations of the first n prime numbers.

Original entry on oeis.org

0, 0, 1, 0, 0, 0, 3, 4, 3, 2, -1, 1, 3, 3, 1, 1, -1, -3, 0, 1, 4, 3, 4, 5, 8, 9, 8, 7, 6, 7, 2, 6, 10, 12, 14, 14, 14, 16, 16, 16, 16, 16, 12, 16, 18, 18, 18, 14, 14, 14, 14, 10, 10, 6, 13, 16, 19, 20, 23, 26, 27, 30, 31, 30, 31, 30, 31, 34, 33, 32, 35, 34, 31, 30, 27, 22, 25, 26, 29, 30, 31, 32, 29, 30, 27, 24, 27, 28, 27, 24, 23, 18, 15, 12, 9, 4, -1, 5, 9, 11
Offset: 1

Views

Author

Andrea Fornaciari, May 26 2019

Keywords

Comments

By "edge truncated" we mean removing the first and last digit. For prime(3)=5 which has binary representation 101 edge truncating yields the string '0'. If there are 2 digits, then edge truncation yields the empty string ''. We count zero 1's and zero 0's in the empty string. The only cases of this are prime(1)=2 and prime(2)=3 which have binary representations 10 and 11.

Crossrefs

Programs

  • PARI
    s=0; forprime (p=2, 541, print1 (s += #binary(p\2)+1-2*hammingweight(p\2) ", ")) \\ Rémy Sigrist, Jul 13 2019
    
  • Python
    import gmpy2
    def dec2bin(x):
        return str(bin(x))[2:]
    def digitBalance(string):
        s = 0
        for char in string:
            if int(char) > 0:
                s -= 1
            else:
                s += 1
        return s
    N = 100 # number of terms
    seq = [0]
    prime = 2
    for i in range(N-1):
        prime = gmpy2.next_prime(prime)
        binary = dec2bin(prime)
        truncated = binary[1:-1]
        term = seq[-1] + digitBalance(truncated)
        seq.append(term)
    print(seq) # Jonas K. Sønsteby, May 27 2019
    
  • Sage
    def A308430list(b):
        L = []; s = 0
        for p in prime_range(2, b):
            q = (p//2).digits(2)
            s += 1 + len(q) - 2*sum(q)
            L.append(s)
        return L
    print(A308430list(542)) # Peter Luschny, Jul 13 2019

Formula

a(n) = a(n-1) + bitlength(prime(n)2) - 2 * popcount(prime(n)_2) + 2, n > 1. - _Sean A. Irvine, May 27 2019
a(n) = Sum_{k=2..n} (A035100(k) - 2*A014499(k) + 2) = Sum_{k=2..n} (A070939(A000040(k)) - 2*A000120(A000040(k)) + 2). - Daniel Suteu, Jul 13 2019
Showing 1-10 of 11 results. Next