login
The OEIS is supported by the many generous donors to the OEIS Foundation.

 

Logo
Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
A115884 Numbers k such that the k-th prime plus k gives a palindrome. 6

%I #30 Jun 16 2022 03:17:24

%S 1,2,3,4,22,45,66,71,75,88,94,97,103,105,116,140,331,432,454,565,646,

%T 703,795,1042,1108,1168,1248,1334,1644,1652,1864,1874,1900,2181,2295,

%U 2323,2485,2509,2585,2679,2835,2899,2923,3052,3360,3372,3396,3404

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

%H 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 prime(103) + 103 = 666, a palindrome; so 103 is term.

%p filter:= proc(n) local p,L;

%p p:= ithprime(n)+n;

%p L:= convert(p,base,10);

%p ListTools:-Reverse(L) = L

%p end proc:

%p select(filter, [$1..10000]); # _Robert Israel_, Nov 04 2014

%t 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 palQ[n_] := Reverse[x = IntegerDigits[n]] == x; Select[Range[3405], palQ[Prime[#] + #] &] (* _Jayanta Basu_, Jun 24 2013 *)

%o (PARI) ispal(n) = my(e=digits(n));e == Vecrev(e) \\ A002113

%o for(k=1,10^6,b=k+prime(k);if(ispal(b),print1(k,", "))) \\ _Alexandru Petrescu_, Jun 15 2022

%o (Python)

%o from sympy import nextprime

%o def ispal(n): s = str(n); return s == s[::-1]

%o def agen(): # generator of terms

%o k, pk = 1, 2

%o while True:

%o if ispal(k+pk): yield k

%o k, pk = k+1, nextprime(pk)

%o g = agen()

%o print([next(g) for n in range(1, 51)]) # _Michael S. Branicky_, Jun 15 2022

%Y Cf. A014688, A084122, A115885, A115888.

%K nonn,base

%O 1,2

%A _Giovanni Resta_, Feb 06 2006

Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Style Sheet | Transforms | Superseeker | Recents
The OEIS Community | Maintained by The OEIS Foundation Inc.

License Agreements, Terms of Use, Privacy Policy. .

Last modified April 24 08:28 EDT 2024. Contains 371927 sequences. (Running on oeis4.)