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.

Previous Showing 11-20 of 37 results. Next

A095077 Primes with four 1-bits in their binary expansion.

Original entry on oeis.org

23, 29, 43, 53, 71, 83, 89, 101, 113, 139, 149, 163, 197, 263, 269, 277, 281, 293, 337, 353, 389, 401, 449, 523, 547, 593, 643, 673, 773, 1031, 1049, 1061, 1091, 1093, 1097, 1217, 1283, 1289, 1297, 1409, 1553, 1601, 2069, 2083, 2089, 2129
Offset: 1

Views

Author

Antti Karttunen, Jun 01 2004

Keywords

Crossrefs

Subsequence of A027699. First differs from A085448 at n = 19, where a(n)=337, while A085448 continues from there with 311, whose binary expansion has six 1-bits, not four. Cf. A095057.
Cf. A000215 (primes having two bits set), A081091 (three bits set).
Cf. A264908.

Programs

  • Mathematica
    Select[Prime[Range[320]], Plus@@IntegerDigits[#, 2] == 4 &] (* Alonso del Arte, Jan 11 2011 *)
    Select[ Flatten[ Table[2^i + 2^j + 2^k + 1, {i, 3, 11}, {j, 2, i - 1}, {k, j - 1}]], PrimeQ] (* Robert G. Wilson v, Jul 30 2016 *)
  • PARI
    bits1_4(x) = { nB = floor(log(x)/log(2)); z = 0;
    for(i=0,nB,if(bittest(x,i),z++;if(z>4,return(0););););
    if(z == 4, return(1);, return(0););};
    forprime(x=17,2129,if(bits1_4(x),print1(x, ", ");););
    \\ Washington Bomfim, Jan 11 2011
    
  • PARI
    is(n)=isprime(n) && hammingweight(n)==4 \\ Charles R Greathouse IV, Jul 30 2016
    
  • PARI
    list(lim)=my(v=List(),t); for(a=3,logint(lim\=1,2), for(b=2,a-1, for(c=1,b-1, t=1<lim, return(Vec(v))); if(isprime(t), listput(v,t))))); Vec(v) \\ Charles R Greathouse IV, Jul 30 2016
    
  • Python
    from itertools import count, islice
    from sympy import isprime
    from sympy.utilities.iterables import multiset_permutations
    def A095077_gen(): # generator of terms
        return filter(isprime,map(lambda s:int('1'+''.join(s)+'1',2),(s for l in count(2) for s in multiset_permutations('0'*(l-2)+'11'))))
    A095077_list = list(islice(A095077_gen(),30)) # Chai Wah Wu, Jul 19 2022

A130911 a(n) is the number of primes with odd binary weight among the first n primes minus the number with an even binary weight.

Original entry on oeis.org

1, 0, -1, 0, 1, 2, 1, 2, 1, 0, 1, 2, 3, 2, 3, 2, 3, 4, 5, 4, 5, 6, 5, 4, 5, 4, 5, 6, 7, 6, 7, 8, 9, 8, 7, 8, 9, 8, 9, 10, 11, 12, 13, 14, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 21, 20, 19, 20, 19, 18, 19, 18, 19, 18, 19, 18, 19, 18, 17, 16, 15, 14, 15, 14, 15, 14, 13, 14, 13, 14, 15, 16, 17, 18, 19, 20, 19, 20, 19, 20, 19, 18, 19, 20, 21, 20, 19
Offset: 1

Views

Author

T. D. Noe, Jun 08 2007

Keywords

Comments

Prime race between evil primes (A027699) and odious primes (A027697).
Shevelev conjectures that a(n) >= 0 for n > 3. Surprisingly, the conjecture also appears to be true if we count zeros instead of ones in the binary representation of prime numbers.
The conjecture is true for primes up to at least 10^13. Mauduit and Rivat prove that half of all primes are evil. - T. D. Noe, Feb 09 2009

Crossrefs

Cf. A156549 (race between primes having an odd/even number of zeros in binary).

Programs

  • Mathematica
    cnt=0; Table[p=Prime[n]; If[EvenQ[Count[IntegerDigits[p,2],1]], cnt--, cnt++ ]; cnt, {n,10000}]
    Accumulate[If[OddQ[DigitCount[#,2,1]],1,-1]&/@Prime[Range[100]]] (* Harvey P. Dale, Aug 09 2013 *)
  • PARI
    f(p)={v=binary(p);s=0;for(k=1,#v,if(v[k]==1,s++)); return(s%2)};nO=0;nE=0;forprime(p=2,520,if(f(p),nO++, nE++);an=nO-nE;print1(an,", ")) \\ Washington Bomfim, Jan 14 2011
    
  • Python
    from sympy import nextprime
    from itertools import islice
    def agen():
        p, evod = 2, [0, 1]
        while True:
            yield evod[1] - evod[0]
            p = nextprime(p); evod[bin(p).count('1')%2] += 1
    print(list(islice(agen(), 97))) # Michael S. Branicky, Dec 21 2021

Formula

a(n) = (number of odious primes <= prime(n)) - (number of evil primes <= prime(n)).
a(n) = A200247(n) - A200246(n).

Extensions

Edited by N. J. A. Sloane, Nov 16 2011

A066148 Primes with an even number of 0's in binary expansion.

Original entry on oeis.org

3, 7, 19, 31, 43, 53, 67, 73, 79, 97, 103, 107, 109, 127, 139, 149, 163, 197, 271, 283, 307, 313, 331, 367, 379, 397, 409, 419, 421, 431, 433, 439, 443, 457, 463, 487, 491, 499, 523, 547, 571, 593, 599, 619, 643, 673, 683, 691, 739, 751, 773, 797, 811, 821
Offset: 1

Views

Author

R. K. Guy, Dec 13 2001

Keywords

Crossrefs

Programs

  • Mathematica
    Select[Prime[Range[200]],EvenQ[DigitCount[#,2,0]]&] (* Harvey P. Dale, Mar 04 2017 *)
  • PARI
    a066148(m) = local(p,v,z); forprime(p=2,m,v=binary(p); z=0; for(j=1,matsize(v)[2], if(v[j]==0,z++)); if(z%2==0,print1(p,",")))
    a066148(850)
    
  • PARI
    f(p)={v=binary(p);s=0;for(k=1,#v,if(v[k]==0, s++));return(1-s%2)};forprime(p=3,821,if(f(p),print1(p,", "))) \\ Washington Bomfim, Jan 14 2011
    
  • PARI
    forprime(p=2, 10^3, if( #select(x->x==0, digits(p,2))%2==0, print1(p,", "))); \\ Joerg Arndt, Jun 16 2018

Extensions

More terms from Vladeta Jovovic and Klaus Brockhaus, Dec 13 2001

A066149 Primes with an odd number of 0's in binary expansion.

Original entry on oeis.org

2, 5, 11, 13, 17, 23, 29, 37, 41, 47, 59, 61, 71, 83, 89, 101, 113, 131, 137, 151, 157, 167, 173, 179, 181, 191, 193, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 277, 281, 293, 311, 317, 337, 347, 349, 353, 359, 373, 383, 389, 401, 449, 461
Offset: 1

Views

Author

R. K. Guy, Dec 13 2001

Keywords

Examples

			17 is in the sequence because 17 is a prime and 17 = 10001_2. '10001' has three 0's. - _Indranil Ghosh_, Feb 06 2017
		

Crossrefs

Programs

  • Mathematica
    Select[ Prime[ Range[ PrimePi[ 1000 ] ] ], OddQ[ Count[ IntegerDigits[ #, 2 ], 0 ] ]& ]
  • PARI
    forprime(p=2, 10^3, if( #select(x->x==0, digits(p, 2))%2==1, print1(p, ", "))); \\ Joerg Arndt, Jun 16 2018

Extensions

More terms from Vladeta Jovovic and Klaus Brockhaus, Dec 13 2001

A027698 Numbers k such that the k-th prime has an odd number of 1's in its binary expansion.

Original entry on oeis.org

1, 4, 5, 6, 8, 11, 12, 13, 15, 17, 18, 19, 21, 22, 25, 27, 28, 29, 31, 32, 33, 36, 37, 39, 40, 41, 42, 43, 44, 46, 47, 48, 49, 50, 51, 52, 53, 54, 58, 61, 63, 65, 67, 73, 75, 78, 80, 81, 82, 83, 84, 85, 86, 88, 90, 93, 94, 95, 98, 100, 102, 103, 104, 106, 107, 110, 111, 112
Offset: 1

Views

Author

Keywords

Crossrefs

Programs

  • Mathematica
    Select[ Range[ 150 ], OddQ[ Length[ Cases[ IntegerDigits[ Prime[ # ], 2 ], 1 ] ] ]& ]
    Select[Range[200],OddQ[DigitCount[Prime[#],2,1]]&] (* Harvey P. Dale, Sep 19 2021 *)

Extensions

More terms from Erich Friedman

A027700 Numbers k such that the k-th prime has an even number of 1's in its binary expansion.

Original entry on oeis.org

2, 3, 7, 9, 10, 14, 16, 20, 23, 24, 26, 30, 34, 35, 38, 45, 55, 56, 57, 59, 60, 62, 64, 66, 68, 69, 70, 71, 72, 74, 76, 77, 79, 87, 89, 91, 92, 96, 97, 99, 101, 105, 108, 109, 114, 117, 122, 124, 125, 131, 133, 137, 139, 141, 142, 146, 147, 148, 150, 152, 154, 155, 159, 165, 166, 170, 173, 176, 178
Offset: 1

Views

Author

Keywords

Crossrefs

Programs

  • Mathematica
    Position[Table[If[EvenQ[DigitCount[n,2,1]],1,0],{n,Prime[Range[ 200]]}],1]//Flatten (* Harvey P. Dale, Jul 11 2017 *)
  • PARI
    n=0;forprime(p=2,97,n++;if(hammingweight(p)%2==0,print1(n", "))) \\ Charles R Greathouse IV, Sep 24 2012

Extensions

Extended (and corrected) by Scott Lindhurst (ScottL(AT)alumni.princeton.edu)

A095282 Primes whose binary-expansion ends with an even number of 1's.

Original entry on oeis.org

2, 3, 11, 19, 43, 47, 59, 67, 79, 83, 107, 131, 139, 163, 179, 191, 211, 227, 239, 251, 271, 283, 307, 331, 347, 367, 379, 419, 431, 443, 463, 467, 491, 499, 523, 547, 563, 571, 587, 619, 643, 659, 683, 691, 719, 739, 751, 787, 811, 827, 859
Offset: 1

Views

Author

Antti Karttunen, Jun 04 2004

Keywords

Crossrefs

Intersection of A000040 & (complement of A079523). Complement of A095283 in A000040. Cf. A027699, A095292.

Programs

  • Maple
    q:= proc(n) local i, l, r; l, r:= convert(n, base, 2), 0;
          for i to nops(l) while l[i]=1 do r:=r+1 od; is(r, even)
        end:
    select(q, [ithprime(i)$i=1..200])[];  # Alois P. Heinz, Dec 15 2019
  • Mathematica
    been1Q[n_]:=Module[{c=Split[IntegerDigits[n,2]][[-1]]},c[[1]]==1&&EvenQ[ Length[ c]]]; Join[{2},Select[Prime[Range[150]],been1Q]] (* Harvey P. Dale, Dec 14 2019 *)
  • PARI
    is(n)=valuation(n+1,2)%2==0 && isprime(n) \\ Charles R Greathouse IV, Oct 09 2013

A268476 Balanced evil primes: primes with an even number of runs of 1's in their binary expansion.

Original entry on oeis.org

5, 11, 13, 17, 19, 23, 29, 47, 59, 61, 67, 71, 79, 97, 103, 113, 131, 149, 173, 181, 191, 193, 199, 223, 227, 239, 241, 251, 257, 263, 271, 277, 293, 331, 337, 347, 349, 373, 383, 421, 449, 463, 479, 487, 499, 503, 509, 557, 587, 593, 599, 601, 613, 617, 619
Offset: 1

Views

Author

Vladimir Shevelev, Feb 05 2016

Keywords

Comments

Primes in A268412. Complement of A268477.

Crossrefs

Programs

  • Mathematica
    Select[Prime@ Range@ 120, EvenQ@ Length[Split@ IntegerDigits[#, 2] /. {0, _} -> Nothing] &] (* Michael De Vlieger, Feb 08 2016 *)
  • Python
    from sympy import prime
    A268476_list = [p for p in (prime(i) for i in range(1,10**6)) if not len(list(filter(bool,format(p,'b').split('0')))) % 2] # Chai Wah Wu, Mar 01 2016

Extensions

More terms from Peter J. C. Moses, Feb 05 2016

A268477 Balanced odious primes: primes with an odd number of runs of 1's in their binary expansion.

Original entry on oeis.org

2, 3, 7, 31, 37, 41, 43, 53, 73, 83, 89, 101, 107, 109, 127, 137, 139, 151, 157, 163, 167, 179, 197, 211, 229, 233, 269, 281, 283, 307, 311, 313, 317, 353, 359, 367, 379, 389, 397, 401, 409, 419, 431, 433, 439, 443, 457, 461, 467, 491, 521, 523, 541, 547, 563
Offset: 1

Views

Author

Vladimir Shevelev, Feb 05 2016

Keywords

Comments

Primes from A268415.
According to our 2007-conjecture, if pi_1(m) is the number of evil primes (A027699) not exceeding m and pi_2(m) is the number of odious primes (A027697) not exceeding m, then pi_1(m)<=pi_2(m) for all natural m except m=5 and m=6.
In the "balance" case of A268476,A268477, most likely, none of two types of primes
is in the majority beginning with any place.

Crossrefs

Programs

  • Mathematica
    Select[Prime@ Range@ 108, OddQ@ Length[Split@ IntegerDigits[#, 2] /. {0, _} -> Nothing] &] (* Michael De Vlieger, Feb 08 2016 *)
  • Python
    from sympy import prime
    A268477_list = [p for p in (prime(i) for i in range(1,10**6)) if len(list(filter(bool,format(p,'b').split('0')))) % 2] # Chai Wah Wu, Mar 01 2016

Extensions

More terms from Peter J. C. Moses, Feb 05 2016

A357761 a(n) = A227872(n) - A356018(n).

Original entry on oeis.org

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

Views

Author

Amiram Eldar, Oct 12 2022

Keywords

Comments

The excess of the number of odious (A000069) divisors of n over the number of evil (A001969) divisors of n.
Every integer occurs in this sequence.

Crossrefs

Cf. A000005, A000069, A000290 (positions of odd terms), A001969, A027697, A027699, A106400, A227872, A230851 (positions of 0's), A356018, A357762.
Similar sequences: A046660, A048272.

Programs

  • Mathematica
    a[n_] := -DivisorSum[n, (-1)^DigitCount[#, 2, 1] &]; Array[a, 100]
  • PARI
    a(n) = -sumdiv(n, d, (-1)^hammingweight(d));

Formula

a(n) = -Sum_{d|n} A106400(d).
a(n) = A000005(n) - 2*A356018(n).
a(n) = 2*A227872(n) - A000005(n).
a(n) = 0 iff n is in A230851.
a(n) == 1 (mod 2) iff n is a square (A000290).
a(2^n) = n + 1.
a(p*2^n) = 0 when p is an evil prime (A027699).
a(p^2*2^n) = n + 1 when p is an evil prime (A027699) and p^2 is odious, and when p is an odd odious prime (A027697) and p^2 is evil.
a(p^2*2^n) = -(n+1) when p is an evil prime and p^2 is also evil.
a(p^2*2^n) = 3*(n+1) when p is an odd odious prime and p^2 is also odious.
Asymptotic mean: Limit_{m->oo} (1/m) * Sum_{k=1..m} a(k) = -Sum_{k>=1} A106400(k)/k = 1.196283264... (A357762).
Previous Showing 11-20 of 37 results. Next