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.

Showing 1-2 of 2 results.

A028989 Smallest palindromic prime with 2n-1 digits.

Original entry on oeis.org

2, 101, 10301, 1003001, 100030001, 10000500001, 1000008000001, 100000323000001, 10000000500000001, 1000000008000000001, 100000000212000000001, 10000000000300000000001, 1000000000016100000000001, 100000000000080000000000001, 10000000000000300000000000001
Offset: 1

Views

Author

Keywords

Crossrefs

Odd-numbered terms of A056732. - Edward Catmur, May 01 2015
Cf. A100027.

Programs

  • Mathematica
    t={}; Do[p=NextPrime[10^(2*n)]; While[Reverse[x=IntegerDigits[p]]!=x,p=NextPrime[p]]; AppendTo[t,p],{n,0,6}]; t (* Jayanta Basu, Jun 05 2013 *)
  • PARI
    a(n)={
    n--;
    my(N=100^n+1,aS=10^(n+3)+10^(n-3),bS=10^(n+2)+10^(n-2),cS=10^(n+1)+10^(n-1),dS=10^n);
    forstep(a=N,N+9*aS,aS,
    forstep(b=a,a+9*bS,bS,
    forstep(c=b,b+9*cS,cS,
    forstep(d=c,c+9*dS,dS,
    if(ispseudoprime(d),return(d))
    ))));
    warning("could not find a("n")")
    }; \\ Charles R Greathouse IV, Feb 15 2011
    
  • PARI
    a(n)=for(j=10^(n-1),10^n-1,d=digits(j);p=fromdigits(vector(2*n-1,x,if(xJeppe Stig Nielsen, Feb 20 2021

Extensions

a(10) corrected by Farideh Firoozbakht, Oct 10 2005

A115941 a(n) is the least prime whose representation contains a palindromic substring of length n.

Original entry on oeis.org

2, 11, 101, 11113, 10301, 1011013, 1003001, 100110013, 100030001, 10000000019, 10000500001, 1000011000017, 1000008000001, 100000440000011, 100000323000001, 10000001100000011, 10000000500000001, 1000000011000000019, 1000000008000000001, 100000000660000000013
Offset: 1

Views

Author

Giovanni Resta, Feb 06 2006

Keywords

Examples

			a(6)=1011013 since it is the least prime that contains a palindromic substring (101101) of length 6.
		

Crossrefs

Cf. A056732.

Programs

  • Python
    from sympy import isprime
    from itertools import product
    def pals_to_test(n, odd=True):
      if n <= 2: yield [2, 11][n-1]
      if odd: ruled_out = "024568" # can't be even or multiple of 5
      else: ruled_out = "0"
      midrange = [[""], [str(i) for i in range(10)]]
      for p in product("0123456789", repeat=n//2):
        left = "".join(p)
        if len(left):
          if left[0] in ruled_out: continue
        for middle in midrange[n%2]:
            out = left+middle+left[::-1]
            if odd: yield out
            else:
              for last in "1379": yield out+last
    def a(n):
      palsgen = pals_to_test(n, n%2 == 1)
      while True:
        strpal = next(palsgen)
        pal = int(strpal)
        if isprime(pal): return pal
    print([a(n) for n in range(1, 18)]) # Michael S. Branicky, Feb 11 2021

Extensions

a(18) and beyond from Michael S. Branicky, Feb 11 2021
Showing 1-2 of 2 results.