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

A036378 Number of primes p between powers of 2, 2^n < p <= 2^(n+1).

Original entry on oeis.org

1, 1, 2, 2, 5, 7, 13, 23, 43, 75, 137, 255, 464, 872, 1612, 3030, 5709, 10749, 20390, 38635, 73586, 140336, 268216, 513708, 985818, 1894120, 3645744, 7027290, 13561907, 26207278, 50697537, 98182656, 190335585, 369323305, 717267168, 1394192236, 2712103833
Offset: 0

Views

Author

Keywords

Comments

Number of primes whose binary order (A029837) is n+1, i.e., those with ceiling(log_2(p)) = n+1. [corrected by Jon E. Schoenfield, May 13 2018]
First differences of A007053. This sequence illustrates how far the Bertrand postulate is oversatisfied.
Scaled for Ramanujan primes as in A190501, A190502.
This sequence appears complete such that any nonnegative number can be written as a sum of distinct terms of this sequence. The sequence has been checked for completeness up to the gap between 2^46 and 2^47. Assuming that after 2^46 the formula x/log(x) is a good approximation to primepi(x), it can be proved that 2*a(n) > a(n+1) for all n >= 46, which is a sufficient condition for completeness. [Frank M Jackson, Feb 02 2012]

Examples

			The 7 primes for which A029837(p)=6 are 37, 41, 43, 47, 53, 59, 61.
		

Crossrefs

Programs

  • Magma
    [1,1] cat [#PrimesInInterval(2^n, 2^(n+1)): n in [2..29]]; // Vincenzo Librandi, Nov 18 2014
  • Mathematica
    t = Table[PrimePi[2^n], {n, 0, 20}]; Rest@t - Most@t (* Robert G. Wilson v, Mar 20 2006 *)
  • PARI
    a(n) = primepi(1<<(n+1))-primepi(1<
    				

Formula

a(n) = primepi(2^(n+1)) - primepi(2^n).
a(n) = A095005(n)+A095006(n) = A095007(n) + A095008(n) = A095013(n) + A095014(n) = A095015(n) + A095016(n) (for n > 1) = A095021(n) + A095022(n) + A095023(n) + A095024(n) = A095019(n) + A095054(n) = A095020(n) + A095055(n) = A095060(n) + A095061(n) = A095063(n) + A095064(n) = A095094(n) + A095095(n).

Extensions

More terms from Labos Elemer, May 13 2004
Entries checked by Robert G. Wilson v, Mar 20 2006

A095018 a(n) is the number of primes p which have exactly n zeros and n ones when written in binary.

Original entry on oeis.org

1, 0, 2, 4, 17, 28, 189, 531, 1990, 5747, 23902, 76658, 291478, 982793, 3677580, 13214719, 49161612, 177190667, 664806798, 2443387945
Offset: 1

Views

Author

Antti Karttunen, Jun 01 2004

Keywords

Comments

a(n) is the number of terms in A066196 which lie between 2^(2n-1) and 2^2n inclusively.

Examples

			a(1) = 1 since only 2_10 = 10_2 satisfies the criterion;
a(2) = 0 since there is no prime between 4 and 16 which meets the criterion.
The only primes in the range ]2^5,2^6[ with equal numbers of ones and zeros in their binary expansion are 37 (in binary 100101) and 41 (in binary 101011) thus a(3)=2.
a(4) = 4 since 139, 149, 163 and 197 meet the criterion; etc.
		

Crossrefs

Programs

  • Mathematica
    f[n_] := Block[{c = 0, p = NextPrime[2^(2n -1) -1], lmt = 2^(2n)}, While[p < lmt, If[DigitCount[p, 2, 1] == n, c++]; p = NextPrime@ p]; c]; Array[f, 17] (* K. D. Bajpai and Robert G. Wilson v, Jan 10 2017 *)
  • Python
    from itertools import combinations
    from sympy import isprime
    def A095018(n): return sum(1 for d in combinations((1<Chai Wah Wu, Jul 18 2025

Extensions

Edited by N. J. A. Sloane, Jan 16 2017
a(18)-a(20) from Amiram Eldar, Nov 21 2020

A095005 Number of odious primes (A027697) in range ]2^n,2^(n+1)].

Original entry on oeis.org

0, 1, 2, 2, 5, 8, 19, 20, 48, 75, 160, 242, 505, 835, 1761, 2799, 5890, 10250, 20921, 36872, 74316, 134816, 267749, 492286, 977207, 1823657, 3598657, 6779899, 13336543, 25358424, 49763462, 95140695, 186504600, 358630024, 702300885, 1356118149, 2654709953, 5142968571
Offset: 1

Author

Antti Karttunen and Labos Elemer, Jun 01 2004

Keywords

Crossrefs

Programs

  • Mathematica
    Table[Count[Prime@ Range[PrimePi[2^n] + 1, PrimePi[2^(n + 1) - 1]], k_ /; OddQ@ First@ DigitCount[k, 2]], {n, 24}] (* Michael De Vlieger, Feb 25 2017 *)
  • PARI
    a(n) = #select(x->((hammingweight(x)%2)==1),primes([2^n+1,2^(n+1)])); \\ Michel Marcus, Feb 26 2017

Formula

a(n) = A036378(n) - A095006(n).

Extensions

a(34)-a(38) from Amiram Eldar, Jun 20 2024

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

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

A095292 Number of A095282-primes in range ]2^n,2^(n+1)].

Original entry on oeis.org

1, 0, 1, 1, 3, 4, 9, 14, 23, 47, 88, 152, 295, 540, 1004, 1933, 3572, 6805, 12909, 24461, 46767, 89481, 171327, 328638, 631302, 1215243, 2342291, 4520976, 8736608, 16899331, 32727125, 63446234, 123106396
Offset: 1

Author

Antti Karttunen, Jun 04 2004

Keywords

Crossrefs

a(n) = A036378(n)-A095293(n). Cf. A095006.

Programs

A127977 The minimum excess in the prime race of odious primes versus evil primes in the interval (2^(n-1),2^n).

Original entry on oeis.org

0, 1, 4, 7, 13, 19, 39, 53, 104, 138, 251, 334, 590, 715, 1353, 1855, 3659, 5221, 10484, 14933, 27491, 35474, 68816, 97342, 186405, 265255
Offset: 5

Author

Jonathan Vos Post, Jun 07 2007

Keywords

Comments

Shevelev conjectures (p.2) that for all natural numbers n other than 5 and 6, the number of evil primes not exceeding n <= the number of odious primes not exceeding n. Odious primes are A027697. Evil primes are A027699.

Examples

			OdiPrimePi(x) for x >= 32 is 6, 6, 6, 6, 6, 7, 7, 7, 7, 8,.. and EviPrimePi(x) for x>=32 is 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6,...
The difference OdiPrimePi(x)-EviPrimePi(x) is 1, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 2, 2, 2, 2, 3,.. so the minimum of the difference in the interval 2^(6-1)..2^6 is 1, yielding a(6)=1.
		

Programs

  • Maple
    read("transforms") ; # see oeis.org/transforms.txt
    isA000069 := proc(n) type(wt(n),'odd') ; end proc;
    isA027697 := proc(n) isprime(n) and isA000069(n) ; end proc:
    isA027699 := proc(n) isprime(n) and not isA000069(n) ; end proc:
    odiPi := proc(n) option remember; if n = 0 then 0; else an1 := procname(n-1) ; if isA027697(n) then an1+1 ; else an1 ; end if; end if; end proc:
    eviPi := proc(n) option remember; if n = 0 then 0; else an1 := procname(n-1) ; if isA027699(n) then an1+1 ; else an1 ; end if; end if; end proc:
    oddPi := proc(n) odiPi(n)-eviPi(n) ; end proc:
    A127977 := proc(n) local a,x ; a := 2^(n+1) ; for x from 2^(n-1)+1 to 2^n-1 do a := min(a,oddPi(x)) ; end do: a; end proc:
    for n from 5 do print(n,A127977(n)) ; end do; # R. J. Mathar, Sep 03 2011
  • Mathematica
    wt[n_] := DigitCount[n, 2, 1];
    isA000069[n_] := OddQ[wt[n]];
    isA027697[n_] := PrimeQ[n] && isA000069[n];
    isA027699[n_] := PrimeQ[n] && !isA000069[n];
    odiPi[n_] := odiPi[n] = If[n==0, 0, an1 = odiPi[n-1]; If[isA027697[n], an1+1, an1]];
    eviPi[n_] := eviPi[n] = If[n==0, 0, an1 = eviPi[n-1]; If[isA027699[n], an1+1, an1]];
    oddPi[n_] := odiPi[n] - eviPi[n];
    A127977[n_] := Module[{a, x}, a = 2^(n+1); For[x = 2^(n-1)+1, x <= 2^n-1, x++, a = Min[a, oddPi[x]]]; a];
    Table[an = A127977[n]; Print[an]; an, {n, 5, 30}] (* Jean-François Alcover, Jan 23 2018, after R. J. Mathar *)

Extensions

Published numbers corrected and checked up to n=23 by R. J. Mathar, Sep 03 2011
Showing 1-6 of 6 results.