|
|
A308777
|
|
Number of twin primes between p and p^2 (inclusive) where p is the n-th prime.
|
|
1
|
|
|
1, 3, 6, 9, 16, 19, 32, 35, 42, 58, 61, 82, 96, 101, 122, 148, 174, 183, 220, 242, 247, 276, 304, 332, 374, 404, 417, 436, 447, 468, 552, 576, 630, 641, 730, 749, 788, 822, 864, 910, 960, 985, 1082, 1095, 1134, 1149, 1252, 1370, 1416, 1433, 1464, 1528, 1545, 1636, 1702
(list;
graph;
refs;
listen;
history;
text;
internal format)
|
|
|
OFFSET
|
1,2
|
|
COMMENTS
|
Similar sequences given in cross-references have further information and references; in particular A273257 has much more efficient PARI code. - M. F. Hasler, Jun 27 2019
|
|
LINKS
|
|
|
EXAMPLE
|
There is a single twin prime (3) between 2 and 4, so a(1) = 1.
There are 3 twin primes (3, 5 and 7) between 3 and 9, so a(2) = 3.
|
|
MAPLE
|
a:= n-> (p-> add(`if`(isprime(j) and (isprime(j-2) or
isprime(j+2)), 1, 0), j=p..p^2))(ithprime(n)):
|
|
MATHEMATICA
|
a[n_] := With[{p = Prime[n]}, Sum[Boole[PrimeQ[k] && (PrimeQ[k-2] || PrimeQ[k+2])], {k, p, p^2}]];
|
|
PROG
|
(PARI) a(n) = my(p=prime(n)); sum(k=p, p^2, isprime(k) && (isprime(k-2) || isprime(k+2)));
(Python)
from sympy import prime, prevprime, nextprime
if n == 1:
return 1
c, p = 0, prime(n)
p2, x = p**2, [prevprime(p), p , nextprime(p)]
while x[1] <= p2:
if x[1] - x[0] == 2 or x[2] - x[1] == 2:
c += 1
x = x[1:] + [nextprime(x[2])]
|
|
CROSSREFS
|
Cf. A143738 (twin primes between n and n^2), A273257 (twin pairs between prime(n) and prime(n)^2).
|
|
KEYWORD
|
nonn
|
|
AUTHOR
|
|
|
STATUS
|
approved
|
|
|
|