login
A103405
The 2^n-th palindromic prime.
0
2, 3, 7, 151, 757, 14341, 36563, 1114111, 1793971, 7256527, 115737511, 188646881, 746676647, 11984748911, 19541414591, 75174747157, 1192238322911, 1901840481091, 7382419142837, 115344262443511, 181836161638181
OFFSET
1,1
EXAMPLE
2, 3, 5, 7, 11, 101, 131, 151, 181, 191, 313, 353, 373, 383, 727 and 757 are the first sixteen palindromic primes.
MATHEMATICA
NextPalindrome[n_] := Block[ {lg = Floor@ Log[10, n] + 1, idn = IntegerDigits@ n}, If[ Union@ idn == {9}, Return[n + 2], If[lg < 2, Return[n + 1], If[ FromDigits@ Reverse@ Take[ idn, Ceiling[lg/2]] > FromDigits@ Take[ idn, -Ceiling[lg/2]], FromDigits@ Join[ Take[ idn, Ceiling[lg/2]], Reverse@ Take[ idn, Floor[lg/2]]], idfhn = FromDigits@ Take[ idn, Ceiling[lg/2]] + 1; idp = FromDigits@ Join[ IntegerDigits@ idfhn, Drop[ Reverse@ IntegerDigits@ idfhn, Mod[lg, 2]]] ]]]];
c = 0; pal = 0; Do[ While[c < 2^n, pal = NextPalindrome@ pal; If[ PrimeQ@ pal, c++ ]]; Print@ pal, {n, 0, 20}]
CROSSREFS
Cf. A083816.
Sequence in context: A088856 A173913 A007013 * A087311 A053924 A130060
KEYWORD
base,nonn
AUTHOR
Robert G. Wilson v, Feb 04 2005, corrected Nov 16 2006
STATUS
approved