login
A359120
Number of primes p with 10^(n-1) < p < 10^n such that 10^n-p is also prime.
2
3, 11, 47, 221, 1433, 9579, 69044, 519260, 4056919, 32504975, 266490184, 2224590493, 18850792161
OFFSET
1,1
COMMENTS
The terms of A358310 come in decreasing blocks; a(n) is the length of the n-th block.
EXAMPLE
For n = 1, there are three primes p with 1 < p < 10 such that 10-p is also prime, 3, 5, and 7, so a(1) = 3.
PROG
(PARI) a(n) = {if(n==1, return(3)); my(res=0, pow10=10^n); forprime(p=2, 10^(n-1), if(isprime(pow10-p), res++)); forprime(p=10^(n-1), pow10>>1, if(isprime(pow10-p), res+=2)); res} \\ David A. Corneth, Dec 17 2022
(Python)
from sympy import isprime, primerange
def a(n):
lb, ub = 10**(n-1), 10**n
s1 = sum(1 for p in primerange(1, lb) if isprime(ub-p))
s2 = sum(2 for p in primerange(lb, 5*lb) if isprime(ub-p))
return s1 + s2 + int(n == 1)
print([a(n) for n in range(1, 8)]) # Michael S. Branicky, Dec 17 2022
CROSSREFS
A107318 and A065577 are very similar.
Sequence in context: A217216 A301409 A295539 * A174347 A062146 A216947
KEYWORD
nonn,more
AUTHOR
N. J. A. Sloane, Dec 17 2022
EXTENSIONS
a(7)-a(9) from Michael S. Branicky, Dec 17 2022
a(10)-a(11) from David A. Corneth, Dec 17 2022
a(12) from N. J. A. Sloane, Dec 17 2022, found using Corneth's PARI program.
a(13) from Martin Ehrenstein, Dec 18 2022, found using Walisch's primesieve library.
STATUS
approved