login
A115884
Numbers k such that the k-th prime plus k gives a palindrome.
6
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,2
LINKS
Michael S. Branicky, Table of n, a(n) for n = 1..10000 (terms 1..1000 from Harvey P. Dale)
EXAMPLE
prime(103) + 103 = 666, a palindrome; so 103 is a term.
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 *)
PROG
(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
CROSSREFS
KEYWORD
nonn,base
AUTHOR
Giovanni Resta, Feb 06 2006
STATUS
approved