OFFSET
1,1
COMMENTS
It appears that a(n) = 0 for n in A124665.
891, a term of A124665 and with a(891) = 9, is the first counterexample. - Michael S. Branicky, Aug 01 2022
LINKS
Michel Marcus, Table of n, a(n) for n = 1..10000
EXAMPLE
For n=1, the resulting set is (10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 21, 31, 41, 51, 61, 71, 81, 91) where the least prime 11 is at position 2, so a(1) = 2.
For n=2, the resulting set is (12, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 32, 42, 52, 62, 72, 82, 92) where the least prime 23 is at position 5, so a(2) = 5.
MATHEMATICA
Table[Function[w, If[IntegerQ[#], #, 0] &@ FirstPosition[Rest@ Union@ Flatten@ Table[FromDigits@ Insert[w, d, k], {k, Length[w] + 1, 1, -1}, {d, 0, 9}], _?PrimeQ][[1]]][IntegerDigits[n]], {n, 80}] (* Michael De Vlieger, Aug 01 2022 *)
PROG
(PARI) get(d, rd, n, k) = {if (n==0, return(fromdigits(concat(d, k)))); if (n==#d, return(fromdigits(concat(k, d)))); my(v = concat(Vec(d, #d-n), k)); v = concat(v, Vecrev(Vec(rd, n))); fromdigits(v); }
a(n) = {my(d=digits(n), rd = Vecrev(d), list = List(), p); for (n=0, #d, my(kstart = if (n==#d, 1, 0)); for (k=kstart, 9, listput(list, get(d, rd, n, k)); ); ); my(svec = Set(Vec(list))); for (k=1, #svec, if (isprime(svec[k]), return(k)); ); }
(Python)
from sympy import isprime
def a(n):
s = str(n)
out = set(s[:i]+c+s[i:] for i in range(len(s)+1) for c in "0123456789")
out = sorted(int(k) for k in out if k[0] != "0")
ptest = (i for i, k in enumerate(sorted(out), 1) if isprime(int(k)))
return next(ptest, 0)
print([a(n) for n in range(1, 81)]) # Michael S. Branicky, Aug 01 2022
CROSSREFS
KEYWORD
nonn,base
AUTHOR
Michel Marcus, Aug 01 2022
STATUS
approved