login

Year-end appeal: Please make a donation to the OEIS Foundation to support ongoing development and maintenance of the OEIS. We are now in our 61st year, we have over 378,000 sequences, and we’ve reached 11,000 citations (which often say “discovered thanks to the OEIS”).

Number of primes p with 10^(n-1) < p < 10^n such that 10^n-p is also prime.
2

%I #28 Dec 18 2022 08:26:21

%S 3,11,47,221,1433,9579,69044,519260,4056919,32504975,266490184,

%T 2224590493,18850792161

%N Number of primes p with 10^(n-1) < p < 10^n such that 10^n-p is also prime.

%C The terms of A358310 come in decreasing blocks; a(n) is the length of the n-th block.

%e 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.

%o (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

%o (Python)

%o from sympy import isprime, primerange

%o def a(n):

%o lb, ub = 10**(n-1), 10**n

%o s1 = sum(1 for p in primerange(1, lb) if isprime(ub-p))

%o s2 = sum(2 for p in primerange(lb, 5*lb) if isprime(ub-p))

%o return s1 + s2 + int(n == 1)

%o print([a(n) for n in range(1, 8)]) # _Michael S. Branicky_, Dec 17 2022

%Y A107318 and A065577 are very similar.

%Y Cf. A006879, A358310.

%K nonn,more

%O 1,1

%A _N. J. A. Sloane_, Dec 17 2022

%E a(7)-a(9) from _Michael S. Branicky_, Dec 17 2022

%E a(10)-a(11) from _David A. Corneth_, Dec 17 2022

%E a(12) from _N. J. A. Sloane_, Dec 17 2022, found using Corneth's PARI program.

%E a(13) from _Martin Ehrenstein_, Dec 18 2022, found using Walisch's primesieve library.