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.

This page as a plain text file.
%I A115884 #33 Oct 29 2024 15:36:40
%S A115884 1,2,3,4,22,45,66,71,75,88,94,97,103,105,116,140,331,432,454,565,646,
%T A115884 703,795,1042,1108,1168,1248,1334,1644,1652,1864,1874,1900,2181,2295,
%U A115884 2323,2485,2509,2585,2679,2835,2899,2923,3052,3360,3372,3396,3404
%N A115884 Numbers k such that the k-th prime plus k gives a palindrome.
%H A115884 Michael S. Branicky, <a href="/A115884/b115884.txt">Table of n, a(n) for n = 1..10000</a> (terms 1..1000 from Harvey P. Dale)
%e A115884 prime(103) + 103 = 666, a palindrome; so 103 is a term.
%p A115884 filter:= proc(n) local p,L;
%p A115884    p:= ithprime(n)+n;
%p A115884    L:= convert(p,base,10);
%p A115884    ListTools:-Reverse(L) = L
%p A115884 end proc:
%p A115884 select(filter, [$1..10000]); # _Robert Israel_, Nov 04 2014
%t A115884 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 *)
%t A115884 palQ[n_] := Reverse[x = IntegerDigits[n]] == x; Select[Range[3405], palQ[Prime[#] + #] &] (* _Jayanta Basu_, Jun 24 2013 *)
%o A115884 (PARI) ispal(n) = my(e=digits(n));e == Vecrev(e) \\ A002113
%o A115884 for(k=1,10^6,b=k+prime(k);if(ispal(b),print1(k,", "))) \\ _Alexandru Petrescu_, Jun 15 2022
%o A115884 (Python)
%o A115884 from sympy import nextprime
%o A115884 def ispal(n): s = str(n); return s == s[::-1]
%o A115884 def agen(): # generator of terms
%o A115884     k, pk = 1, 2
%o A115884     while True:
%o A115884         if ispal(k+pk): yield k
%o A115884         k, pk = k+1, nextprime(pk)
%o A115884 g = agen()
%o A115884 print([next(g) for n in range(1, 51)]) # _Michael S. Branicky_, Jun 15 2022
%Y A115884 Cf. A014688, A084122, A115885, A115888.
%K A115884 nonn,base
%O A115884 1,2
%A A115884 _Giovanni Resta_, Feb 06 2006