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

A095020 Number of one-bit dominant primes (A095070) in range ]2^n,2^(n+1)].

Original entry on oeis.org

1, 2, 2, 4, 5, 10, 16, 32, 48, 97, 175, 334, 529, 1130, 1850, 3953, 6276, 13911, 23248, 49564, 81622, 178910, 300311, 650703, 1091809, 2380394, 4062176, 8780393, 15021634, 32618497, 56134342, 121625616, 209889612, 455265038, 791458830, 1711760073, 2982211935, 6457387921, 11302458576, 24430016732
Offset: 1

Views

Author

Antti Karttunen, Jun 01 2004

Keywords

Crossrefs

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))

A095075 Primes in whose binary expansion the number of 1-bits is less than or equal to number of 0-bits.

Original entry on oeis.org

2, 17, 37, 41, 67, 73, 97, 131, 137, 139, 149, 163, 193, 197, 257, 263, 269, 277, 281, 293, 337, 353, 389, 401, 449, 521, 523, 541, 547, 557, 563, 569, 577, 587, 593, 601, 613, 617, 641, 643, 647, 653, 659, 661, 673, 677, 709, 769, 773, 787
Offset: 1

Views

Author

Antti Karttunen, Jun 01 2004

Keywords

Examples

			From _Indranil Ghosh_, Feb 03 2017: (Start)
17 is in the sequence because 17_10 = 10001_2. '10001' has two 1's and three 0's.
37 is in the sequence because 37_10 = 100101_2. '100101' has three 1's and 3 0's. (End)
		

Crossrefs

Complement of A095070 in A000040.
Cf. A095055.

Programs

  • Mathematica
    Select[Prime[Range[150]], Differences[DigitCount[#, 2]][[1]] >= 0 &] (* Amiram Eldar, Jul 25 2023 *)
    Select[Prime[Range[150]],DigitCount[#,2,1]<=DigitCount[#,2,0]&] (* Harvey P. Dale, Sep 27 2023 *)
  • PARI
    B(x) = {nB = floor(log(x)/log(2)); z1 = 0; z0 = 0;
    for(i = 0, nB, if(bittest(x,i), z1++;, z0++;); );
    if(z1 <= z0, return(1);, return(0););};
    forprime(x = 2, 787, if(B(x), print1(x, ", "); ); );
    \\ Washington Bomfim, Jan 11 2011
    
  • Python
    from sympy import isprime
    i=1
    j=1
    while j<=250:
        if isprime(i) and bin(i)[2:].count("1")<=bin(i)[2:].count("0"):
            print(str(j)+" "+str(i))
            j+=1
        i+=1 # Indranil Ghosh, Feb 03 2017

A095073 Primes in whose binary expansion the number of 1-bits is one more than the number of 0-bits.

Original entry on oeis.org

5, 19, 71, 83, 89, 101, 113, 271, 283, 307, 313, 331, 397, 409, 419, 421, 433, 457, 1103, 1117, 1181, 1223, 1229, 1237, 1303, 1307, 1319, 1381, 1427, 1429, 1433, 1481, 1489, 1559, 1579, 1607, 1613, 1619, 1621, 1637, 1699, 1733, 1811, 1861
Offset: 1

Views

Author

Antti Karttunen, Jun 01 2004

Keywords

Examples

			71 is in the sequence because 71_10 = 1000111_2. '1000111' has four 1's and three 0's. - _Indranil Ghosh_, Feb 03 2017
		

Crossrefs

Intersection of A000040 and A031448. Subset of A095070. Cf. A095053.

Programs

  • Mathematica
    Select[Prime[Range[500]], Differences[DigitCount[#, 2]] == {-1} &]
  • PARI
    { forprime(p=2, 2000,
      v=binary(p); s=0;
      for(k=1,#v, s+=if(v[k]==1,+1,-1));
      if(s==1,print1(p,", "))
    ) }
    
  • Python
    from sympy import isprime
    i=1
    j=1
    while j<=25000:
        if isprime(i) and bin(i)[2:].count("1")-bin(i)[2:].count("0")==1:
            print(str(j)+" "+str(i))
            j+=1
        i+=1 # Indranil Ghosh, Feb 03 2017

A095286 Primes in whose binary expansion the number of 1 bits is > 1 + number of 0 bits.

Original entry on oeis.org

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

Views

Author

Antti Karttunen, Jun 04 2004

Keywords

Examples

			13 is in the sequence because 13 is prime and 13 = 1101_2. '1101' has three 1's and one 0. 3 > 1 + 1. - _Indranil Ghosh_, Feb 07 2017
		

Crossrefs

Complement of A095287 in A000040. Subset of A095070. Subset: A095314. Cf. also A095296.

Programs

  • PARI
    B(x) = {nB = floor(log(x)/log(2)); b1 = 0; b0 = 0;
    for(i = 0, nB, if(bittest(x,i), b1++;, b0++;); );
    if(b1 > (b0+1), return(1);, return(0);); };
    forprime(x = 3, 499, if(B(x), print1(x, ", "); ); );
    \\ Washington Bomfim, Jan 11 2011
    
  • Python
    from sympy import isprime
    i = 1
    j = 1
    while j <= 2000:
        bi = bin(i)[2:]
        if isprime(i) and bi.count("1") > 1 + bi.count("0"):
            print(str(j) + " " + str(i))
            j += 1
        i += 1 # Indranil Ghosh, Feb 07 2017

A372538 Numbers k such that the number of ones minus the number of zeros in the binary expansion of the k-th prime number is 1.

Original entry on oeis.org

3, 8, 20, 23, 24, 26, 30, 58, 61, 63, 65, 67, 78, 80, 81, 82, 84, 88, 185, 187, 194, 200, 201, 203, 213, 214, 215, 221, 225, 226, 227, 234, 237, 246, 249, 253, 255, 256, 257, 259, 266, 270, 280, 284, 287, 290, 573, 578, 586, 588, 591, 593, 611, 614, 615, 626
Offset: 1

Views

Author

Gus Wiseman, May 13 2024

Keywords

Examples

			The binary expansion of 83 is (1,0,1,0,0,1,1) with ones minus zeros 4 - 3 = 1, and 83 is the 23rd prime, so 23 is in the sequence.
The primes A000040(a(n)) together with their binary expansions and binary indices begin:
     5:           101 ~ {1,3}
    19:         10011 ~ {1,2,5}
    71:       1000111 ~ {1,2,3,7}
    83:       1010011 ~ {1,2,5,7}
    89:       1011001 ~ {1,4,5,7}
   101:       1100101 ~ {1,3,6,7}
   113:       1110001 ~ {1,5,6,7}
   271:     100001111 ~ {1,2,3,4,9}
   283:     100011011 ~ {1,2,4,5,9}
   307:     100110011 ~ {1,2,5,6,9}
   313:     100111001 ~ {1,4,5,6,9}
   331:     101001011 ~ {1,2,4,7,9}
   397:     110001101 ~ {1,3,4,8,9}
   409:     110011001 ~ {1,4,5,8,9}
   419:     110100011 ~ {1,2,6,8,9}
   421:     110100101 ~ {1,3,6,8,9}
   433:     110110001 ~ {1,5,6,8,9}
   457:     111001001 ~ {1,4,7,8,9}
  1103:   10001001111 ~ {1,2,3,4,7,11}
  1117:   10001011101 ~ {1,3,4,5,7,11}
  1181:   10010011101 ~ {1,3,4,5,8,11}
  1223:   10011000111 ~ {1,2,3,7,8,11}
		

Crossrefs

Restriction of A031448 to the primes, positions of ones in A145037.
Taking primes gives A095073, negative A095072.
Positions of ones in A372516, absolute value A177718.
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 the length of an integer's binary expansion.
A101211 lists run-lengths in binary expansion, row-lengths A069010.
A372471 lists binary indices of primes.

Programs

  • Mathematica
    Select[Range[1000],DigitCount[Prime[#],2,1]-DigitCount[Prime[#],2,0]==1&]

A225222 Primes with more than twice as many 1's as 0's in binary.

Original entry on oeis.org

3, 7, 11, 13, 23, 29, 31, 47, 59, 61, 79, 103, 107, 109, 127, 191, 223, 239, 251, 367, 379, 383, 431, 439, 443, 463, 479, 487, 491, 499, 503, 509, 607, 631, 701, 719, 727, 733, 743, 751, 757, 761, 823, 827, 829, 859, 863, 877, 883, 887, 911, 919, 941, 947, 953, 967, 971
Offset: 1

Views

Author

Keywords

Comments

Naslund proves that this sequence (and related ones) is infinite and gives an asymptotic upper bound.

Crossrefs

Programs

  • Mathematica
    okQ[n_] := Module[{b = IntegerDigits[n, 2]}, Count[b, 1] > 2*Count[b, 0]]; Select[Prime[Range[200]], okQ] (* T. D. Noe, May 02 2013 *)
  • PARI
    has(n)=3*hammingweight(n)>2*#binary(n)
    select(has,primes(500))

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.

A340466 Primes whose binary expansion contains more 1's than 0's but at least one 0.

Original entry on oeis.org

5, 11, 13, 19, 23, 29, 43, 47, 53, 59, 61, 71, 79, 83, 89, 101, 103, 107, 109, 113, 151, 157, 167, 173, 179, 181, 191, 199, 211, 223, 227, 229, 233, 239, 241, 251, 271, 283, 307, 311, 313, 317, 331, 347, 349, 359, 367, 373, 379, 383, 397, 409, 419, 421, 431
Offset: 1

Views

Author

Ctibor O. Zizka, Jan 08 2021

Keywords

Examples

			71 is in the sequence because 71 is a prime and 71_10 = 1000111_2. '1000111' has four 1's and three 0's.
		

Crossrefs

Programs

  • Mathematica
    Select[Range[400], PrimeQ[#] && First[d = DigitCount[#, 2]] > Last[d] > 0 &] (* Amiram Eldar, Jan 08 2021 *)
  • PARI
    isok(n) = if (isprime(n), my(nb=#binary(n), h=hammingweight(n)); (2*h > nb) && (h < nb)); \\ Michel Marcus, Jan 10 2021
    
  • Python
    from sympy import sieve
    A340466_list = [p for p in sieve.primerange(1,10**4) if len(bin(p))-2 < 2*bin(p).count('1') < 2*len(bin(p))-4] # Chai Wah Wu, Jan 10 2021

Formula

{ A095070 } minus { A000225 }.
{ A095070 } minus { A000668 }.
{ A095070 } intersect { A138837 }.
Showing 1-9 of 9 results.