OFFSET
1,1
COMMENTS
EXAMPLE
a(3) = 101 since its reversal is also 101;
a(4) = 1231 since its reversal is 1321 which is also prime and their difference is minimal at 90;
a(6) = 105601 since its reversal is 106501 which is also prime and their difference is minimal at 900;
a(8) = 10012001 since its reversal is 10021001 which is also prime and their difference is minimal at 9000; etc.
MATHEMATICA
fe[n_] := Block[{k = 1, j, p, q}, While[ j = k(10^IntegerLength[k]) + IntegerReverse[k +1]; p = 10^(2 n -1) + j(10^(n - IntegerLength[j]/2)) + 1; q = IntegerReverse@ p; !PrimeQ@ p || !PrimeQ@ q, k++; If[ Mod[k, 10] == 9, k++]]; p]; fe[1] = 11;
fo[n_] := Block[{k = 0, j, p}, While[ j = k(10^(IntegerLength[k] -1)) + IntegerReverse@ Quotient[k, 10]; p = 10^(2n -2) + j(10^(n - (IntegerLength[j] + 1)/2)) +1; !PrimeQ@ p, k++]; p];
a[n_] := If[ OddQ@ n, fo[(n +1)/2], fe[n/2]]; Array[a, 21]
CROSSREFS
KEYWORD
base,nonn
AUTHOR
Robert G. Wilson v, Jul 05 2024
STATUS
approved