OFFSET
1,1
EXAMPLE
2, 23, 239, 23911, etc., are primes.
MATHEMATICA
NextPalindrome[n_] := Block[{l = Floor[ Log[10, n] + 1], idn = IntegerDigits[n]}, If[ Union[idn] == {9}, Return[n + 2], If[l < 2, Return[n + 1], If[ FromDigits[ Reverse[ Take[ idn, Ceiling[l/2]]]] FromDigits[ Take[ idn, -Ceiling[l/2]]], FromDigits[ Join[ Take[ idn, Ceiling[l/2]], Reverse[ Take[ idn, Floor[l/2]]]]], idfhn = FromDigits[ Take[ idn, Ceiling[l/2]]] + 1; idp = FromDigits[ Join[ IntegerDigits[ idfhn], Drop[ Reverse[ IntegerDigits[ idfhn]], Mod[l, 2]]]]]]]]; a = 2; k = 2; f[n_, m_] := Block[{k = NextPalindrome[m]}, While[b = FromDigits[ Join[ IntegerDigits[n], IntegerDigits[k]]]; !PrimeQ[b], k = NextPalindrome[k]]; Return[b]]; f[2, 2]; f[%, 3]; etc.
CROSSREFS
KEYWORD
base,nonn
AUTHOR
Amarnath Murthy, Sep 22 2003
EXTENSIONS
Edited, corrected and extended by Robert G. Wilson v, Sep 27 2003
STATUS
approved