A057199 The first nontrivial (k>n+2) palindromic prime in both bases n and n+2 or -1 if it does not exist.
5, 1667, 7517, 34853363, 116755331881, 20537111057, 373
Offset: 2
Examples
a(3) = 1667 because it is the first prime > 5 which is a palindrome in both base 3 and 5.
Programs
-
Mathematica
f[n_] := Block[{k = n + 3}, While[a = IntegerDigits[k, n]; b = IntegerDigits[k, n + 2]; ! PrimeQ[k] || a != Reverse[a] || b != Reverse[b], k++]; k]; Do[ Print[{n, f[n] // Timing}], {n, 2, 10}]
Extensions
a(6)-a(8) from Giovanni Resta, Feb 28 2013
Comments