OFFSET
1,3
COMMENTS
Both p and p+2 must appear in the indicated range, and a prime can only be used once (so (3, 5) and (5, 7) can't both be used).
It appears that there should be more twin primes between prime(n) and prime(n)^2 as n increases. Specifically this sequence should be strictly increasing.
Indeed even the number of twin primes between prime(n)^2 and prime(n+1)^2 (A057767) seems to have a lower bound of about n/11. - M. F. Hasler, Jun 27 2019
LINKS
Charles R Greathouse IV, Table of n, a(n) for n = 1..10000
EXAMPLE
For n=3, prime(3)=5 because it is the 5th prime. There are 3 twin prime subsets on the set {5,6,7,...,24,25} so the 3rd term is 3.
MATHEMATICA
Table[Function[w, Length@ Select[Prime[Range @@ w], Function[p, And[# - p == 2, # < Prime@ Last@ w] &@ NextPrime@ p]]]@ {n, PrimePi[Prime[n]^2]}, {n, 55}] (* Michael De Vlieger, Aug 30 2016 *)
ntp[n_]:=Count[Partition[Select[Range[Prime[n], Prime[n]^2], PrimeQ], 2, 1], _?(#[[2]]-#[[1]]==2&)]; Join[{0, 1}, Array[ntp, 60, 3]] (* Harvey P. Dale, Nov 01 2016 *)
PROG
(PARI) a(n)=if(n<3, return(n-1)); my(p=prime(n), q=p, s); forprime(r=q+1, p^2, if(r-q==2, s++); q=r); s \\ Charles R Greathouse IV, Aug 28 2016
CROSSREFS
KEYWORD
nonn
AUTHOR
Jesse H. Crotts, Aug 28 2016
EXTENSIONS
More terms from Charles R Greathouse IV, Aug 28 2016
STATUS
approved