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.

A115884 Numbers k such that the k-th prime plus k gives a palindrome.

Original entry on oeis.org

1, 2, 3, 4, 22, 45, 66, 71, 75, 88, 94, 97, 103, 105, 116, 140, 331, 432, 454, 565, 646, 703, 795, 1042, 1108, 1168, 1248, 1334, 1644, 1652, 1864, 1874, 1900, 2181, 2295, 2323, 2485, 2509, 2585, 2679, 2835, 2899, 2923, 3052, 3360, 3372, 3396, 3404
Offset: 1

Views

Author

Giovanni Resta, Feb 06 2006

Keywords

Examples

			prime(103) + 103 = 666, a palindrome; so 103 is a term.
		

Crossrefs

Programs

  • Maple
    filter:= proc(n) local p,L;
       p:= ithprime(n)+n;
       L:= convert(p,base,10);
       ListTools:-Reverse(L) = L
    end proc:
    select(filter, [$1..10000]); # Robert Israel, Nov 04 2014
  • Mathematica
    palQ[n_]:=Module[{idn=IntegerDigits[n]},idn==Reverse[idn]]; With[ {nn=3500}, Rest[Flatten[Position[Total/@Thread[{Prime[Range[nn]], Range[nn]}],?(palQ)]]]] (* _Harvey P. Dale, Oct 11 2011 *)
    palQ[n_] := Reverse[x = IntegerDigits[n]] == x; Select[Range[3405], palQ[Prime[#] + #] &] (* Jayanta Basu, Jun 24 2013 *)
  • PARI
    ispal(n) = my(e=digits(n));e == Vecrev(e) \\ A002113
    for(k=1,10^6,b=k+prime(k);if(ispal(b),print1(k,", "))) \\ Alexandru Petrescu, Jun 15 2022
    
  • Python
    from sympy import nextprime
    def ispal(n): s = str(n); return s == s[::-1]
    def agen(): # generator of terms
        k, pk = 1, 2
        while True:
            if ispal(k+pk): yield k
            k, pk = k+1, nextprime(pk)
    g = agen()
    print([next(g) for n in range(1, 51)]) # Michael S. Branicky, Jun 15 2022