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.

Original entry on oeis.org

3, 11, 47, 221, 1433, 9579, 69044, 519260, 4056919, 32504975, 266490184, 2224590493, 18850792161
Offset: 1

Views

Author

N. J. A. Sloane, Dec 17 2022

Keywords

Comments

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

Examples

			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.
		

Crossrefs

A107318 and A065577 are very similar.

Programs

  • 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

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.