cp's OEIS Frontend

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.

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

This page as a plain text file.
%I A359120 #28 Dec 18 2022 08:26:21
%S A359120 3,11,47,221,1433,9579,69044,519260,4056919,32504975,266490184,
%T A359120 2224590493,18850792161
%N A359120 Number of primes p with 10^(n-1) < p < 10^n such that 10^n-p is also prime.
%C A359120 The terms of A358310 come in decreasing blocks; a(n) is the length of the n-th block.
%e A359120 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 A359120 (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 A359120 (Python)
%o A359120 from sympy import isprime, primerange
%o A359120 def a(n):
%o A359120     lb, ub = 10**(n-1), 10**n
%o A359120     s1 = sum(1 for p in primerange(1, lb) if isprime(ub-p))
%o A359120     s2 = sum(2 for p in primerange(lb, 5*lb) if isprime(ub-p))
%o A359120     return s1 + s2 + int(n == 1)
%o A359120 print([a(n) for n in range(1, 8)]) # _Michael S. Branicky_, Dec 17 2022
%Y A359120 A107318 and A065577 are very similar.
%Y A359120 Cf. A006879, A358310.
%K A359120 nonn,more
%O A359120 1,1
%A A359120 _N. J. A. Sloane_, Dec 17 2022
%E A359120 a(7)-a(9) from _Michael S. Branicky_, Dec 17 2022
%E A359120 a(10)-a(11) from _David A. Corneth_, Dec 17 2022
%E A359120 a(12) from _N. J. A. Sloane_, Dec 17 2022, found using Corneth's PARI program.
%E A359120 a(13) from _Martin Ehrenstein_, Dec 18 2022, found using Walisch's primesieve library.