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

A000720 pi(n), the number of primes <= n. Sometimes called PrimePi(n) to distinguish it from the number 3.14159...

Original entry on oeis.org

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

Views

Author

Keywords

Comments

Partial sums of A010051 (characteristic function of primes). - Jeremy Gardiner, Aug 13 2002
pi(n) and prime(n) are inverse functions: a(A000040(n)) = n and A000040(n) is the least number m such that A000040(a(m)) = A000040(n). A000040(a(n)) = n if (and only if) n is prime. - Jonathan Sondow, Dec 27 2004
See the additional references and links mentioned in A143227. - Jonathan Sondow, Aug 03 2008
A lower bound that gets better with larger N is that there are at least T prime numbers less than N, where the recursive function T is: T = N - N*Sum_{i=0..T(sqrt(N))} A005867(i)/A002110(i). - Ben Paul Thurston, Aug 23 2010
Number of partitions of 2n into exactly two parts with the smallest part prime. - Wesley Ivan Hurt, Jul 20 2013
Equivalent to the Riemann hypothesis: abs(a(n) - li(n)) < sqrt(n)*log(n)/(8*Pi), for n >= 2657, where li(n) is the logarithmic integral (Lowell Schoenfeld). - Ilya Gutkovskiy, Jul 05 2016
The second Hardy-Littlewood conjecture, that pi(x) + pi(y) >= pi(x + y) for integers x and y with min{x, y} >= 2, is known to hold for (x, y) sufficiently large (Udrescu 1975). - Peter Luschny, Jan 12 2021

Examples

			There are 3 primes <= 6, namely 2, 3 and 5, so pi(6) = 3.
		

References

  • M. Abramowitz and I. A. Stegun, eds., Handbook of Mathematical Functions, National Bureau of Standards Applied Math. Series 55, 1964 (and various reprintings), p. 870.
  • Tom M. Apostol, Introduction to Analytic Number Theory, Springer-Verlag, 1976, p. 8.
  • Raymond Ayoub, An Introduction to the Analytic Theory of Numbers, Amer. Math. Soc., 1963; p. 129.
  • Florian Cajori, A History of Mathematical Notations, Dover edition (2012), par. 409.
  • Richard Crandall and Carl Pomerance, Prime Numbers: A Computational Perspective, Springer, NY, 2001; see p. 5.
  • G. H. Hardy and E. M. Wright, An Introduction to the Theory of Numbers, 5th ed., Oxford Univ. Press, 1979, Theorems 6, 7, 420.
  • G. J. O. Jameson, The Prime Number Theorem, Camb. Univ. Press, 2003. [See also the review by D. M. Bressoud (link below).]
  • Władysław Narkiewicz, The Development of Prime Number Theory, Springer-Verlag, 2000.
  • Paulo Ribenboim, The Little Book of Bigger Primes, Springer-Verlag NY 2004. See pp. 132-133, 157-184.
  • József Sándor, Dragoslav S. Mitrinovic and Borislav Crstici, Handbook of Number Theory I, Springer Science & Business Media, 2005, Section VII.1. (For inequalities, etc.).
  • N. J. A. Sloane, A Handbook of Integer Sequences, Academic Press, 1973 (includes this sequence).
  • N. J. A. Sloane and Simon Plouffe, The Encyclopedia of Integer Sequences, Academic Press, 1995 (includes this sequence).
  • Gerald Tenenbaum and Michel Mendès France, Prime Numbers and Their Distribution, AMS Providence RI, 1999.
  • V. Udrescu, Some remarks concerning the conjecture pi(x + y) <= pi(x) + pi(y), Rev. Roumaine Math. Pures Appl. 20 (1975), 1201-1208.

Crossrefs

Closely related:
A099802: Number of primes <= 2n.
A060715: Number of primes between n and 2n (exclusive).
A035250: Number of primes between n and 2n (inclusive).
A038107: Number of primes < n^2.
A014085: Number of primes between n^2 and (n+1)^2.
A007053: Number of primes <= 2^n.
A036378: Number of primes p between powers of 2, 2^n < p <= 2^(n+1).
A006880: Number of primes < 10^n.
A006879: Number of primes with n digits.
A033270: Number of odd primes <= n.
A065855: Number of composites <= n.
For lists of large values of a(n) see, e.g., A005669(n) = a(A002386(n)), A214935(n) = a(A205827(n)).
Related sequences:
Primes (p) and composites (c): A000040, A002808, A065855.
Primes between p(n) and 2*p(n): A063124, A070046; between c(n) and 2*c(n): A376761; between n and 2*n: A035250, A060715, A077463, A108954.
Composites between p(n) and 2*p(n): A246514; between c(n) and 2*c(n): A376760; between n and 2*n: A075084, A307912, A307989, A376759.

Programs

  • Haskell
    a000720 n = a000720_list !! (n-1)
    a000720_list = scanl1 (+) a010051_list  -- Reinhard Zumkeller, Sep 15 2011
    
  • Magma
    [ #PrimesUpTo(n): n in [1..200] ];  // Bruno Berselli, Jul 06 2011
    
  • Maple
    with(numtheory); A000720 := pi; [ seq(A000720(i),i=1..50) ];
  • Mathematica
    A000720[n_] := PrimePi[n]; Table[ A000720[n], {n, 1, 100} ]
    Array[ PrimePi[ # ]&, 100 ]
    Accumulate[Table[Boole[PrimeQ[n]],{n,100}]] (* Harvey P. Dale, Jan 17 2015 *)
  • PARI
    A000720=vector(100,n,omega(n!)) \\ For illustration only; better use A000720=primepi
    
  • PARI
    vector(300,j,primepi(j)) \\ Joerg Arndt, May 09 2008
    
  • Python
    from sympy import primepi
    for n in range(1,100): print(primepi(n), end=', ') # Stefano Spezia, Nov 30 2018
  • Sage
    [prime_pi(n) for n in range(1, 79)]  # Zerinvary Lajos, Jun 06 2009
    

Formula

The prime number theorem gives the asymptotic expression a(n) ~ n/log(n).
For x > 1, pi(x) < (x / log x) * (1 + 3/(2 log x)). For x >= 59, pi(x) > (x / log x) * (1 + 1/(2 log x)). [Rosser and Schoenfeld]
For x >= 355991, pi(x) < (x / log(x)) * (1 + 1/log(x) + 2.51/(log(x))^2 ). For x >= 599, pi(x) > (x / log(x)) * (1 + 1/log(x)). [Dusart]
For x >= 55, x/(log(x) + 2) < pi(x) < x/(log(x) - 4). [Rosser]
For n > 1, A138194(n) <= a(n) <= A138195(n) (Tschebyscheff, 1850). - Reinhard Zumkeller, Mar 04 2008
For n >= 33, a(n) = 1 + Sum_{j=3..n} ((j-2)! - j*floor((j-2)!/j)) (Hardy and Wright); for n >= 1, a(n) = n - 1 + Sum_{j=2..n} (floor((2 - Sum_{i=1..j} (floor(j/i)-floor((j-1)/i)))/j)) (Ruiz and Sondow 2000). - Benoit Cloitre, Aug 31 2003
a(n) = A001221(A000142(n)). - Benoit Cloitre, Jun 03 2005
G.f.: Sum_{p prime} x^p/(1-x) = b(x)/(1-x), where b(x) is the g.f. for A010051. - Franklin T. Adams-Watters, Jun 15 2006
a(n) = A036234(n) - 1. - Jaroslav Krizek, Mar 23 2009
From Enrique Pérez Herrero, Jul 12 2010: (Start)
a(n) = Sum_{i=2..n} floor((i+1)/A000203(i)).
a(n) = Sum_{i=2..n} floor(A000010(n)/(i-1)).
a(n) = Sum_{i=2..n} floor(2/A000005(n)). (End)
Let pf(n) denote the set of prime factors of an integer n. Then a(n) = card(pf(n!/floor(n/2)!)). - Peter Luschny, Mar 13 2011
a(n) = -Sum_{p <= n} mu(p). - Wesley Ivan Hurt, Jan 04 2013
a(n) = (1/2)*Sum_{p <= n} (mu(p)*d(p)*sigma(p)*phi(p)) + sum_{p <= n} p^2. - Wesley Ivan Hurt, Jan 04 2013
a(1) = 0 and then, for all k >= 1, repeat k A001223(k) times. - Jean-Christophe Hervé, Oct 29 2013
a(n) = n/(log(n) - 1 - Sum_{k=1..m} A233824(k)/log(n)^k + O(1/log(n)^{m+1})) for m > 0. - Jonathan Sondow, Dec 19 2013
a(n) = A001221(A003418(n)). - Eric Desbiaux, May 01 2014
a(n) = Sum_{j=2..n} H(-sin^2 (Pi*(Gamma(j)+1)/j)) where H(x) is the Heaviside step function, taking H(0)=1. - Keshav Raghavan, Jun 18 2016
a(A014076(n)) = (1/2) * (A014076(n) + 1) - n + 1. - Christopher Heiling, Mar 03 2017
From Steven Foster Clark, Sep 25 2018: (Start)
a(n) = Sum_{m=1..n} A143519(m) * floor(n/m).
a(n) = Sum_{m=1..n} A001221(m) * A002321(floor(n/m)) where A002321() is the Mertens function.
a(n) = Sum_{m=1..n} |A143519(m)| * A002819(floor(n/m)) where A002819() is the Liouville Lambda summatory function and |x| is the absolute value of x.
a(n) = Sum_{m=1..n} A137851(m)/m * H(floor(n/m)) where H(n) = Sum_{m=1..n} 1/m is the harmonic number function.
a(n) = Sum_{m=1..log_2(n)} A008683(m) * A025528(floor(n^(1/m))) where A008683() is the Moebius mu function and A025528() is the prime-power counting function.
(End)
Sum_{k=2..n} 1/a(k) ~ (1/2) * log(n)^2 + O(log(n)) (de Koninck and Ivić, 1980). - Amiram Eldar, Mar 08 2021
a(n) ~ 1/(n^(1/n)-1). - Thomas Ordowski, Jan 30 2023
a(n) = Sum_{j=2..n} floor(((j - 1)! + 1)/j - floor((j - 1)!/j)) [Mináč, unpublished] (see Ribenboim, pp. 132-133). - Stefano Spezia, Apr 13 2025
a(n) = n - 1 - Sum_{k=2..floor(log_2(n))} pi_k(n), where pi_k(n) is the number of k-almost primes <= n. - Daniel Suteu, Aug 27 2025

Extensions

Additional links contributed by Lekraj Beedassy, Dec 23 2003
Edited by M. F. Hasler, Apr 27 2018 and (links recovered) Dec 21 2018

A035250 Number of primes between n and 2n (inclusive).

Original entry on oeis.org

1, 2, 2, 2, 2, 2, 3, 2, 3, 4, 4, 4, 4, 3, 4, 5, 5, 4, 5, 4, 5, 6, 6, 6, 6, 6, 7, 7, 7, 7, 8, 7, 7, 8, 8, 9, 10, 9, 9, 10, 10, 10, 10, 9, 10, 10, 10, 9, 10, 10, 11, 12, 12, 12, 13, 13, 14, 14, 14, 13, 13, 12, 12, 13, 13, 14, 14, 13, 14, 15, 15, 14, 14, 13, 14, 15
Offset: 1

Views

Author

Keywords

Comments

By Bertrand's Postulate (proved by Chebyshev), there is always a prime between n and 2n, i.e., a(n) is positive for all n.
The number of primes in the interval [n,2*n) is the same sequence as this, except that a(1) = 0. - N. J. A. Sloane, Oct 18 2024
The smallest and largest primes between n and 2n inclusive are A007918 and A060308 respectively. - Lekraj Beedassy, Jan 01 2007
The number of partitions of 2n into exactly two parts with first part prime, n > 1. - Wesley Ivan Hurt, Jun 15 2013

Examples

			The primes between n = 13 and 2n = 26, inclusive, are 13, 17, 19, 23; so a(13) = 4.
a(5) = 2, since 2(5) = 10 has 5 partitions into exactly two parts: (9,1),(8,2),(7,3),(6,4),(5,5).  Two primes are among the first parts: 7 and 5.
		

References

  • Aigner, M. and Ziegler, G. Proofs from The Book (2nd edition). Springer-Verlag, 2001.

Crossrefs

Related sequences:
Primes (p) and composites (c): A000040, A002808, A000720, A065855.
Primes between p(n) and 2*p(n): A063124, A070046; between c(n) and 2*c(n): A376761; between n and 2*n: A035250, A060715, A077463, A108954.
Composites between p(n) and 2*p(n): A246514; between c(n) and 2*c(n): A376760; between n and 2*n: A075084, A307912, A307989, A376759.

Programs

Formula

a(n) = A000720(2*n) - A000720(n-1); a(n) <= A179211(n). - Reinhard Zumkeller, Jul 05 2010
a(A059316(n)) = n and a(m) <> n for m < A059316(n). - Reinhard Zumkeller, Jan 08 2012
a(n) = sum(A010051(k): k=n..2*n). [Reinhard Zumkeller, Jan 08 2012]
a(n) = pi(2n) - pi(n-1). [Wesley Ivan Hurt, Jun 15 2013]

A101909 Number of primes between 2n and 4n.

Original entry on oeis.org

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

Views

Author

Cino Hilliard, Jan 28 2005

Keywords

Crossrefs

Programs

  • Maple
    A101909 := proc(n::integer)
        numtheory[pi](4*n)-numtheory[pi](2*n) ;
    end proc:
    seq(A101909(n),n=1..100) ; # R. J. Mathar, Oct 02 2019
  • Mathematica
    f[n_] := PrimePi[4n] - PrimePi[2n]; Table[ f[n], {n, 76}] (* Robert G. Wilson v, Feb 10 2005 *)
  • PARI
    bet2n4n(n) = { local(c,x,y); forstep(x=2,n,2, c=0; forprime(y=x+1,x+x-1, c++; ); print1(c",") ) }
    
  • PARI
    s=0;vector(100,n,s+=isprime(4*n-1)+isprime(4*n-3)-isprime(2*n-1)) \\ Charles R Greathouse IV, Mar 12 2012

Formula

a(n) = A099802(2*n)-A099802(n). - R. J. Mathar, Oct 02 2019

A139325 Triangle read by rows: T(n,k) = number of primes in the k-th row of the square of the first n^2 odd numbers written consecutively in rows of length n, 1<=k<=n.

Original entry on oeis.org

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

Views

Author

Reinhard Zumkeller, Apr 14 2008

Keywords

Comments

A139326(n) = Min{T(n,k): 1<=k<=n};
A139327(n) = Max{T(n,k): 1<=k<=n};
A139328(n) gives sums of rows;
T(n,1) = A099802(n) - 1.

Crossrefs

Cf. A083415.

A210469 a(n) = n - primepi(2n).

Original entry on oeis.org

0, 0, 0, 0, 1, 1, 1, 2, 2, 2, 3, 3, 4, 5, 5, 5, 6, 7, 7, 8, 8, 8, 9, 9, 10, 11, 11, 12, 13, 13, 13, 14, 15, 15, 16, 16, 16, 17, 18, 18, 19, 19, 20, 21, 21, 22, 23, 24, 24, 25, 25, 25, 26, 26, 26, 27, 27, 28, 29, 30, 31, 32, 33, 33, 34, 34, 35, 36, 36, 36
Offset: 1

Views

Author

Wesley Ivan Hurt, Jan 24 2013

Keywords

Comments

The number of distinct odd composite parts appearing in the partitions of 2n into two parts.
a(n) is the number of odd composite numbers up to 2*n-1. - Michel Marcus, Aug 05 2023

Examples

			a(6) = 1 since 9 is the only odd composite number appearing in the partitions of 2*6 = 12 into two parts. For example, 12 = (1+11) = (2+10) = (3+9) = (4+8) = (5+7) = (6+6). Note that the numbers in the partitions with identical parts are counted only once.
		

Crossrefs

Cf. A099802.
See A224710 for a closely related sequence.

Programs

  • Maple
    with(numtheory);  a:=n->n-pi(2*n);  seq(a(k), k=1..70);
  • Mathematica
    Table[n - PrimePi[2 n], {n, 70}] (* Robert G. Wilson v, Jan 24 2013 *)
  • PARI
    a(n) = n - primepi(2*n); \\ Michel Marcus, Aug 05 2023

Formula

a(n) = n - primepi(2n).

A100637 Trisection of A000720.

Original entry on oeis.org

2, 3, 4, 5, 6, 7, 8, 9, 9, 10, 11, 11, 12, 13, 14, 15, 15, 16, 16, 17, 18, 18, 19, 20, 21, 21, 22, 23, 23, 24, 24, 24, 25, 26, 27, 28, 29, 30, 30, 30, 30, 30, 31, 32, 32, 33, 34, 34, 34, 35
Offset: 0

Views

Author

Giovanni Teofilatto, Dec 04 2004

Keywords

Crossrefs

Programs

  • Sage
    [prime_pi(3*n) for n in range(1, 51)] # Zerinvary Lajos, Jun 06 2009

Extensions

Entry for n = 46 corrected and edited to a(n) = 34 (was 33) by Daniel Forgues, Feb 02 2009

A147844 Difference between the number of distinct prime divisors of (2*n)!/n!^2 and pi(2*n), where pi(x) is the prime counting function.

Original entry on oeis.org

0, 0, 1, 1, 1, 1, 2, 1, 2, 3, 2, 3, 3, 3, 3, 3, 3, 2, 3, 2, 3, 4, 5, 5, 5, 5, 6, 4, 3, 5, 6, 5, 4, 5, 5, 6, 7, 6, 7, 7, 7, 7, 7, 7, 7, 7, 7, 6, 7, 7, 8, 9, 8, 8, 10, 10, 11, 10, 10, 9, 9, 9, 9, 9, 9, 9, 8, 9, 10, 11, 11, 10, 10, 10, 10, 11, 10, 10, 11, 10, 10, 11, 11, 12, 12, 11, 12, 12, 12, 13, 13
Offset: 1

Views

Author

Cino Hilliard, Nov 15 2008

Keywords

Comments

The expression (2*n)!/n!^2 is taken from C(2*n+1,n+1) - C(2*n,n) = ((2*n)!/n!^2)*(n/(n+1)) = Sum_{k=1..n} C(n,k)*C(n,k-1). This was posed in the Yahoo Group MathForFun, see link.

Examples

			(2*10)!/10!^2 = 184756 = 2*2*11*13*17*19 which has 5 distinct divisors. Pi(2*10) = 8. 8-5=3 = a(10).
		

Crossrefs

Programs

  • Magma
    [#PrimesUpTo(2*n) - #PrimeDivisors( Factorial(2*n) div Factorial(n)^2):n in [1..91]]; // Marius A. Burtea, Nov 16 2019
  • Mathematica
    Table[PrimePi[2n]-PrimeNu[(2n)!/(n!)^2],{n,100}] (* Harvey P. Dale, Oct 30 2021 *)
  • PARI
    g2(n) = for(x=1,n,ct=omega((2*x)!/x!^2);print1(primepi(2*x)-ct","))
    
Showing 1-7 of 7 results.