OFFSET
1,3
LINKS
Jens Kruse Andersen, Table of n, a(n) for n = 1..10000
FORMULA
a(n) + A070046(n) = number of numbers between prime(n) and 2*prime(n), which is prime(n)-1. - N. J. A. Sloane, Aug 28 2014
EXAMPLE
2 P 4 = 0,
3 4 P 6 = 1,
5 6 P 8 9 10 = 3,
7 8 9 10 P 12 P 14 = 4,
11 12 P 14 15 16 P 18 P 20 21 22 = 7
and so on.
MAPLE
A246515 := proc(n) local p; p:=ithprime(n); n - 1 + p - numtheory:-pi(2*p - 1); end; # N. J. A. Sloane, Oct 20 2024
[seq(A246515(n), n=1..120)];
MATHEMATICA
Table[Prime[n] - PrimePi[2*Prime[n]] + n - 1, {n, 100}] (* Paolo Xausa, Oct 22 2024 *)
PROG
(PARI) s=[]; forprime(p=2, 1000, n=0; for(q=p+1, 2*p-1, if(!isprime(q), n++)); s=concat(s, n)); s \\ Colin Barker, Aug 28 2014
(PARI) a(n)=prime(n)+n-1-primepi(2*prime(n))
vector(100, n, a(n)) \\ Faster program. Jens Kruse Andersen, Aug 28 2014
(Python)
from sympy import prime, primepi
def A246514(n): return (m:=prime(n))+n-1-primepi(m<<1) # Chai Wah Wu, Oct 22 2024
CROSSREFS
KEYWORD
nonn,easy
AUTHOR
Odimar Fabeny, Aug 28 2014
EXTENSIONS
More terms from Colin Barker, Aug 28 2014
STATUS
approved