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.
%I A308777 #31 Feb 29 2020 16:17:41 %S A308777 1,3,6,9,16,19,32,35,42,58,61,82,96,101,122,148,174,183,220,242,247, %T A308777 276,304,332,374,404,417,436,447,468,552,576,630,641,730,749,788,822, %U A308777 864,910,960,985,1082,1095,1134,1149,1252,1370,1416,1433,1464,1528,1545,1636,1702 %N A308777 Number of twin primes between p and p^2 (inclusive) where p is the n-th prime. %C A308777 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 %H A308777 Chai Wah Wu, <a href="/A308777/b308777.txt">Table of n, a(n) for n = 1..7944</a> %H A308777 Jon S. Birdsey, Geza Schay, <a href="https://arxiv.org/abs/1906.09220">A Sieve for Twin Primes</a>, arXiv:1906.09220 [math.NT], 2019. %e A308777 There is a single twin prime (3) between 2 and 4, so a(1) = 1. %e A308777 There are 3 twin primes (3, 5 and 7) between 3 and 9, so a(2) = 3. %p A308777 a:= n-> (p-> add(`if`(isprime(j) and (isprime(j-2) or %p A308777 isprime(j+2)), 1, 0), j=p..p^2))(ithprime(n)): %p A308777 seq(a(n), n=1..55); # _Alois P. Heinz_, Jun 25 2019 %t A308777 a[n_] := With[{p = Prime[n]}, Sum[Boole[PrimeQ[k] && (PrimeQ[k-2] || PrimeQ[k+2])], {k, p, p^2}]]; %t A308777 Array[a, 55] (* _Jean-François Alcover_, Feb 29 2020 *) %o A308777 (PARI) a(n) = my(p=prime(n)); sum(k=p, p^2, isprime(k) && (isprime(k-2) || isprime(k+2))); %o A308777 (Python) %o A308777 from sympy import prime, prevprime, nextprime %o A308777 def A308777(n): %o A308777 if n == 1: %o A308777 return 1 %o A308777 c, p = 0, prime(n) %o A308777 p2, x = p**2, [prevprime(p), p , nextprime(p)] %o A308777 while x[1] <= p2: %o A308777 if x[1] - x[0] == 2 or x[2] - x[1] == 2: %o A308777 c += 1 %o A308777 x = x[1:] + [nextprime(x[2])] %o A308777 return c # _Chai Wah Wu_, Jun 25 2019 %Y A308777 Cf. A001097 (twin primes), A054272, A057767 (twin pairs between p(n)^2 and p(n+1)^2), A088019. %Y A308777 Cf. A143738 (twin primes between n and n^2), A273257 (twin pairs between prime(n) and prime(n)^2). %K A308777 nonn %O A308777 1,2 %A A308777 _Michel Marcus_, Jun 24 2019