OFFSET
0,1
LINKS
Danny Rorabaugh, Table of n, a(n) for n = 0..10000
EXAMPLE
111 is divisible by 3, and 212 is divisible by 2, but 313 is prime; therefore, a(1) = 313.
MAPLE
f:= proc(n) local dn, x, dx, p;
dn:= 10^(1+ilog10(n));
for x from 1 by 2 do if igcd(x, n) = 1 then
dx:= 10^(1+ilog10(x));
p:= x*(1+dx*dn)+n*dx;
if isprime(p) then return(p) fi
fi od
end proc:
101, seq(f(n), n=1..100); # Robert Israel, Apr 07 2015
# second Maple program:
a:= proc(n) local m, p; for m do
p:= parse(cat(m, n, m));
if isprime(p) then break fi od; p
end:
seq(a(n), n=0..50); # Alois P. Heinz, Mar 16 2020
MATHEMATICA
mnmPrimes = {}; f[m_, n_] := FromDigits[Flatten[{IntegerDigits[m], IntegerDigits[n], IntegerDigits[m]}]]; Do[m = 1; While[True, If[PrimeQ[f[m, n]], AppendTo[mnmPrimes, f[m, n]]; Break[]]; m+=2], {n, 0, 40}]; mnmPrimes
PROG
(PARI) a(n) = {m=1; while (! isprime(p=eval(concat(Str(m), concat(Str(n), Str(m))))), m+=2); p; } \\ Michel Marcus, Mar 23 2015
(Sage)
def A252942(n):
m = 1
sn = str(n)
while True:
sm = str(m)
a = int(sm + sn + sm)
if is_prime(a):
return a
m += 2
A252942(40) # Danny Rorabaugh, Mar 31 2015
(Haskell)
a252942 n = head [y | m <- [1..],
let y = read (show m ++ show n ++ show m) :: Integer, a010051' y == 1]
-- Reinhard Zumkeller, Apr 08 2015
CROSSREFS
KEYWORD
base,easy,nonn
AUTHOR
Ivan N. Ianakiev, Mar 23 2015
STATUS
approved