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.

A040025 a(n) is the number of prime palindromes with 2n+1 digits.

Original entry on oeis.org

4, 15, 93, 668, 5172, 42042, 353701, 3036643, 27045226, 239093865, 2158090933, 19742800564, 180815391365
Offset: 0

Views

Author

Keywords

Examples

			a(1)=15 because Number of prime palindromes with 3 digits is 15. [_Shyam Sunder Gupta_, Mar 14 2009]
		

Crossrefs

Subsequence of A016115, which is the main entry.

Programs

  • PARI
    a(n) = {my(nb = 0); forprime(p=10^(2*n), 10^(2*n+1)-1, if (eval(concat(Vecrev(Str(p)))) == p, nb++);); nb;} \\ Michel Marcus, Jul 24 2015
    
  • Python
    from sympy import isprime
    from itertools import product
    def candidate_pals(n): # of length 2n + 1
      if n == 0: yield from [2, 3, 5, 7]; return # one-digit primes
      for rightbutend in product("0123456789", repeat=n-1):
        rightbutend = "".join(rightbutend)
        for end in "1379": # multi-digit primes must end in 1, 3, 7, or 9
          left = end + rightbutend[::-1]
          for mid in "0123456789": yield int(left + mid + rightbutend + end)
    def a(n): return sum(isprime(p) for p in candidate_pals(n))
    print([a(n) for n in range(6)]) # Michael S. Branicky, Apr 15 2021

Extensions

a(9) from Shyam Sunder Gupta, Feb 12 2006
a(10) from Shyam Sunder Gupta, Mar 14 2009
a(11) from Shyam Sunder Gupta, Oct 05 2013
a(12) from Shyam Sunder Gupta, Dec 19 2024