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-5 of 5 results.

A095054 Number of primes with number of 0-bits <= number of 1-bits (A095074) in range ]2^n,2^(n+1)].

Original entry on oeis.org

1, 2, 2, 4, 7, 10, 20, 32, 65, 97, 203, 334, 718, 1130, 2381, 3953, 8266, 13911, 28995, 49564, 105524, 178910, 376969, 650703, 1383287, 2380394, 5044969, 8780393, 18699214, 32618497, 69349061, 121625616, 259051224, 455265038, 968649497, 1711760073, 3647018733, 6457387921, 13745846521, 24430016732
Offset: 1

Views

Author

Antti Karttunen, Jun 01 2004

Keywords

Crossrefs

Formula

a(n) = A095020(n) + (if n is odd) A095018((n+1)/2).

Extensions

a(34)-a(40) from Amiram Eldar, Jun 13 2024

A372516 Number of ones minus number of zeros in the binary expansion of the n-th prime number.

Original entry on oeis.org

0, 2, 1, 3, 2, 2, -1, 1, 3, 3, 5, 0, 0, 2, 4, 2, 4, 4, -1, 1, -1, 3, 1, 1, -1, 1, 3, 3, 3, 1, 7, -2, -2, 0, 0, 2, 2, 0, 2, 2, 2, 2, 6, -2, 0, 2, 2, 6, 2, 2, 2, 6, 2, 6, -5, -1, -1, 1, -1, -1, 1, -1, 1, 3, 1, 3, 1, -1, 3, 3, -1, 3, 5, 3, 5, 7, -1, 1, -1, 1, 1
Offset: 1

Views

Author

Gus Wiseman, May 13 2024

Keywords

Comments

Absolute value is A177718.

Examples

			The binary expansion of 83 is (1,0,1,0,0,1,1), and 83 is the 23rd prime, so a(23) = 4 - 3 = 1.
		

Crossrefs

The sum instead of difference is A035100, firsts A372684 (primes A104080).
The negative version is A037861(A000040(n)).
Restriction of A145037 to the primes.
The unsigned version is A177718.
- Positions of zeros are A177796, indices of the primes A066196.
- Positions of positive terms are indices of the primes A095070.
- Positions of negative terms are indices of the primes A095071.
- Positions of negative ones are A372539, indices of the primes A095072.
- Positions of ones are A372538, indices of the primes A095073.
- Positions of nonnegative terms are indices of the primes A095074.
- Positions of nonpositive terms are indices of the primes A095075.
A000120 counts ones in binary expansion (binary weight), zeros A080791.
A030190 gives binary expansion, reversed A030308.
A035103 counts zeros in binary expansion of primes, firsts A372474.
A048793 lists binary indices, reverse A272020, sum A029931.
A070939 gives length of binary expansion.
A101211 lists run-lengths in binary expansion, row-lengths A069010.
A372471 lists the binary indices of each prime.

Programs

  • Mathematica
    Table[DigitCount[Prime[n],2,1]-DigitCount[Prime[n],2,0],{n,100}]
    DigitCount[#,2,1]-DigitCount[#,2,0]&/@Prime[Range[100]] (* Harvey P. Dale, May 09 2025 *)

Formula

a(n) = A000120(A000040(n)) - A080791(A000040(n)).
a(n) = A014499(n) - A035103(n).
a(n) = A145037(A000040(n))

A095071 Zero-bit dominant primes, i.e., primes whose binary expansion contains more 0's than 1's.

Original entry on oeis.org

17, 67, 73, 97, 131, 137, 193, 257, 263, 269, 277, 281, 293, 337, 353, 389, 401, 449, 521, 523, 547, 577, 593, 641, 643, 673, 769, 773, 1031, 1033, 1039, 1049, 1051, 1061, 1063, 1069, 1091, 1093, 1097, 1109, 1123, 1129, 1153, 1163, 1171
Offset: 1

Views

Author

Antti Karttunen, Jun 01 2004

Keywords

Examples

			73 is in the sequence because 73 is a prime and 73_10 = 1001001_2. '1001001' has four 0's and one 1. - _Indranil Ghosh_, Jan 31 2017
		

Crossrefs

Complement of A095074 in A000040. Subset: A095072. Cf. A095019.

Programs

  • Mathematica
    Reap[Do[p=Prime[k];id=IntegerDigits[p,2];n=Length@id;If[Count[id,0]>n/2,Sow[p]],{k,200}]][[2,1]]
    (* Zak Seidov *)
    Select[Prime[Range[200]],DigitCount[#,2,0]>DigitCount[#,2,1]&] (* Harvey P. Dale, Nov 28 2024 *)
  • PARI
    B(x) = { nB = floor(log(x)/log(2)); b1 = 0; b0 = 0;
    for(i = 0, nB, if(bittest(x,i), b1++;, b0++;); );
    if(b0 > b1, return(1);, return(0););};
    forprime(x = 2, 1171, if(B(x), print1(x, ", "); ); ); \\ Washington Bomfim, Jan 11 2011
    
  • PARI
    {forprime(p=2,1171,nB=floor(log(p)/log(2));
    sum(i=0,nB,bittest(p,i))<=nB/2&print1(p,","))} \\ Zak Seidov, Jan 11 2011
    
  • Python
    #Program to generate the b-file
    from sympy import isprime
    i=1
    j=1
    while j<=200:
        if isprime(i) and bin(i)[2:].count("0")>bin(i)[2:].count("1"):
            print(str(j)+" "+str(i))
            j+=1
        i+=1 # Indranil Ghosh, Jan 31 2017

A095316 Primes in whose binary expansion the number of 1-bits is > number of 0-bits minus 2.

Original entry on oeis.org

2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 263, 269, 271, 277, 281
Offset: 1

Views

Author

Antti Karttunen, Jun 04 2004

Keywords

Comments

Differs from primes (A000040) first time at n=32, where a(32)=139, while A000040(32)=131, as 131 whose binary expansion is 10000011, with 3 1-bits and 5 0-bits is the first prime excluded from this sequence.

Crossrefs

Complement of A095317 in A000040. Subset of A095320. Subset: A095074. Cf. also A095326.

Programs

  • Mathematica
    Select[Prime[Range[60]],DigitCount[#,2,1]>(DigitCount[#,2,0]-2)&] (* Harvey P. Dale, May 28 2012 *)
  • PARI
    forprime(p=2,281,v=binary(p);s=0;for(k=1,#v,s+=if(v[k]==1,+1,-1));if(s>-2,print1(p,", "))) \\ Washington Bomfim, Jan 13 2011

A350577 Prime numbers in A036991.

Original entry on oeis.org

3, 5, 7, 11, 13, 19, 23, 29, 31, 43, 47, 53, 59, 61, 71, 79, 83, 103, 107, 109, 127, 151, 157, 167, 173, 179, 181, 191, 199, 211, 223, 239, 251, 271, 283, 307, 311, 317, 331, 347, 349, 359, 367, 373, 379, 383, 431, 439, 443, 461, 463, 467, 479, 487, 491, 499
Offset: 1

Views

Author

Gennady Eremin, Jan 07 2022

Keywords

Comments

This sequence includes A000668.
Conjecture: The sequence is infinite. For example, in the first million primes (see A000040) 304208 numbers are terms of A036991.

Crossrefs

Programs

  • Maple
    q:= proc(n) local l, t, i; l:= Bits[Split](n); t:=0;
          for i to nops(l) do t:= t-1+2*l[i];
            if t<0 then return false fi
          od: true
        end:
    select(isprime and q, [$2..500])[];  # Alois P. Heinz, Jan 07 2022
  • Mathematica
    q[n_] := PrimeQ[n] && AllTrue[Accumulate[(-1)^Reverse[IntegerDigits[n, 2]]], # <= 0 &]; Select[Range[500], q] (* Amiram Eldar, Jan 07 2022 *)
  • Python
    from sympy import isprime
    def ok(n):
        if n == 0: return True
        count = {"0": 0, "1": 0}
        for bit in bin(n)[:1:-1]:
            count[bit] += 1
            if count["0"] > count["1"]: return False
        return isprime(n)
    print([k for k in range(3, 500, 2) if ok(k)]) # Michael S. Branicky, Jan 07 2022

Formula

Intersection of A000040 and A036991.
Showing 1-5 of 5 results.