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

A027697 Odious primes: primes with odd number of 1's in binary expansion.

Original entry on oeis.org

2, 7, 11, 13, 19, 31, 37, 41, 47, 59, 61, 67, 73, 79, 97, 103, 107, 109, 127, 131, 137, 151, 157, 167, 173, 179, 181, 191, 193, 199, 211, 223, 227, 229, 233, 239, 241, 251, 271, 283, 307, 313, 331, 367, 379, 397, 409, 419, 421, 431, 433, 439, 443, 457, 463, 487, 491, 499, 521, 541, 557, 563
Offset: 1

Views

Author

Keywords

Comments

Conjecture: a(n) < A027699(n) except for n = 2; verified up to n=5*10^7. Moreover, I conjecture that A027699(n) - a(n) tends to infinity. - Vladimir Shevelev

Crossrefs

Cf. A000069 (odious numbers), A092246 (odd odious numbers)

Programs

  • Maple
    a:=proc(n) local nn: nn:= convert(ithprime(n), base, 2): if `mod`(sum(nn[j], j =1..nops(nn)), 2)=1 then ithprime(n) else end if end proc: seq(a(n),n=1..103); # Emeric Deutsch, Oct 24 2007
  • Mathematica
    Clear[BinSumOddQ];BinSumOddQ[a_]:=Module[{i,s=0},s=0;For[i=1,i<=Length[IntegerDigits[a,2]],s+=Extract[IntegerDigits[a,2],i];i++ ];OddQ[s]]; lst={};Do[p=Prime[n];If[BinSumOddQ[p],AppendTo[lst,p]],{n,4!}];lst (* Vladimir Joseph Stephan Orlovsky, Apr 06 2009 *)
    Select[Prime@ Range@ 120, OddQ@ First@ DigitCount[#, 2] &] (* Michael De Vlieger, Feb 08 2016 *)
  • PARI
    f(p)={v=binary(p);s=0;for(k=1,#v,if(v[k]==1,s++));return(s%2)};
    forprime(p=2, 563, if(f(p), print1(p,", "))) \\ Washington Bomfim, Jan 14 2011
    
  • PARI
    s=[]; forprime(p=2, 1000, if(norml2(binary(p))%2==1, s=concat(s, p))); s \\ Colin Barker, Feb 18 2014
    
  • Python
    from sympy import primerange
    print([n for n in primerange(1, 1001) if bin(n)[2:].count("1")%2]) # Indranil Ghosh, May 03 2017

Extensions

More terms from Scott Lindhurst (ScottL(AT)alumni.princeton.edu)

A027699 Evil primes: primes with even number of 1's in their binary expansion.

Original entry on oeis.org

3, 5, 17, 23, 29, 43, 53, 71, 83, 89, 101, 113, 139, 149, 163, 197, 257, 263, 269, 277, 281, 293, 311, 317, 337, 347, 349, 353, 359, 373, 383, 389, 401, 449, 461, 467, 479, 503, 509, 523, 547, 571, 593, 599, 619, 643, 673, 683, 691, 739, 751, 773, 797, 811
Offset: 1

Views

Author

Keywords

Comments

Comment from Vladimir Shevelev, Jun 01 2007: Conjecture: If pi_1(m) is the number of a(n) not exceeding m and pi_2(m) is the number of A027697(n) not exceeding m then pi_1(m) <= smaller than pi_2(m) for all natural m except m=5 and m=6. I verified this conjecture up to 10^9. Moreover I conjecture that pi_2(m)-pi_1(m) tends to infinity with records at the primes m=2, 13, 41, 61, 67, 79, 109, 131, 137, ...

Crossrefs

Cf. A001969 (evil numbers), A129771 (evil odd numbers)
Cf. A130911 (prime race between evil primes and odious primes).

Programs

  • Mathematica
    Select[Prime[Range[200]], EvenQ[Count[IntegerDigits[ #,2],1]]&] (* T. D. Noe, Jun 12 2007 *)
  • PARI
    forprime(p=1,999,norml2(binary(p))%2 || print1(p","))
    
  • PARI
    isA027699(p)=isprime(p) && !bittest(norml2(binary(p)),0) \\ M. F. Hasler, Dec 12 2010
    
  • Python
    from sympy import isprime
    def ok(n): return bin(n).count("1")%2 == 0 and isprime(n)
    print([k for k in range(812) if ok(k)]) # Michael S. Branicky, Jun 27 2022

Extensions

More terms from Erich Friedman

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

A156549 Race between primes having an odd/even number of zeros in their binary representation.

Original entry on oeis.org

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

Views

Author

T. D. Noe, Feb 09 2009

Keywords

Comments

See A066148 and A066149 for primes with an even/odd number of zeros in their binary representation. Sequence A130911 shows the race between primes having an odd/even number of ones in their binary representation. In this sequence (and A130911), it appears that the primes with an odd number of zeros (or ones) dominate the primes with an even number of zeros (or ones). In general, it appears that the sequences grow for primes having an odd number of bits and "rest" for primes having an even number of bits.

Crossrefs

Programs

  • Mathematica
    cnt=0; Table[p=Prime[n]; If[OddQ[Count[IntegerDigits[p,2],0]], cnt++, cnt-- ]; cnt, {n,100}]
    Accumulate[Table[If[OddQ[DigitCount[p,2,0]],1,-1],{p,Prime[Range[90]]}]] (* Harvey P. Dale, Apr 02 2025 *)
  • PARI
    f(p)={v=binary(p);s=0;for(k=1,#v,if(v[k]==0, s++));return(s%2)}; nO=0;nE=0; forprime(p=2,435,if(f(p), nO++, nE++); an = nO-nE; print1(an,", ")) \\ Washington Bomfim, Jan 14 2011

Formula

a(n) = (number of primes having an odd number of zeros <= prime(n)) - (number of primes having an even number of zeros <= prime(n))
Showing 1-4 of 4 results.