OFFSET
1,1
COMMENTS
Conjecture: Except for n=1 and 3, a(n) = 0 iff prime(n) has Most Significant digit one among (2,4,5,6,8).
LINKS
Robert Israel, Table of n, a(n) for n = 1..10000
EXAMPLE
a(7) = 17471, prime(7) = 17. a(9) = 0, prime(9) = 23 and no such prime exists.
MAPLE
revdigs:= proc(n) local L, i;
L:= convert(n, base, 10);
add(L[-i]*10^(i-1), i=1..nops(L))
end proc:
pali:= proc(n) local d;
d:= ilog10(n);
n*10^d + revdigs(floor(n/10));
end proc:
f:= proc(n) local L, Lp, x, cand, d;
L:= convert(n, base, 10);
if not member(L[-1], [1, 3, 7, 9]) then return 0 fi;
for d from nops(L) to 0 by -1 do
if L[1..d] = ListTools:-Reverse(L[1..d]) then
Lp:= [op(ListTools:-Reverse(L[d+1..-1])), op(L)];
cand:= add(Lp[i]*10^(i-1), i=1..nops(Lp));
if isprime(cand) then return cand fi
fi
od;
for d from 1 do
for x from 0 to 10^d-1 do
cand:= pali(10^d*n+x);
if isprime(cand) then return cand fi;
od;
od
end proc:
f(2):= 2: f(5):= 5:
map(f @ ithprime, [$1..100]); # Robert Israel, Aug 06 2020
CROSSREFS
KEYWORD
AUTHOR
Amarnath Murthy, Sep 26 2003
EXTENSIONS
More terms from Giovanni Resta, Feb 07 2006
STATUS
approved