OFFSET
1,4
LINKS
Robert Israel, Table of n, a(n) for n = 1..10000
Eric Weisstein's World of Mathematics, Bertrand's Postulate
FORMULA
a(n) = primepi(2*prime(n))-n. - Charles R Greathouse IV, Aug 28 2014
a(n) = A063124(n)-1. - N. J. A. Sloane, Oct 19 2024
EXAMPLE
a(1)=1 because between p=2 and 4 there is exactly one prime, 3.
a(10)=6 since six consecutive primes (31,37,41,43,47,53) are located between p(10) = 29 and 58.
MAPLE
N:= 1000: # to get a(n) for n <= pi(N)
Primes:=select(isprime, [$1..N]):
seq(numtheory:-pi(2*Primes[n])-n, n=1..nops(Primes)); # Robert Israel, Aug 28 2014
MATHEMATICA
pp[n_]:=Module[{pr=Prime[n]}, PrimePi[2pr]-n]; Array[pp, 80] (* Harvey P. Dale, Mar 30 2015; edited by Zak Seidov, Oct 18 2022 *)
PROG
(PARI) forprime(p=2, 5000, n=0; for(q=p+1, 2*p-1, if(isprime(q), n++)); print1(n, ", ")) \\ Harry J. Smith, Dec 13 2007, improved by Colin Barker, Aug 28 2014
(PARI) a(n)=primepi(2*prime(n))-n \\ Charles R Greathouse IV, Aug 28 2014
(Python)
from sympy import prime, primepi
def A070046(n): return primepi(prime(n)<<1)-n # Chai Wah Wu, Oct 22 2024
CROSSREFS
KEYWORD
easy,nonn
AUTHOR
Enoch Haga, May 05 2002
EXTENSIONS
Edited by N. J. A. Sloane, May 15 2008 at the suggestion of R. J. Mathar
STATUS
approved