OFFSET
1,1
MAPLE
read("transforms)"):
nleadzero := proc(n, dgs)
local ndgs ;
if n = 0 then
ndgs := 0 ;
else
ndgs := ilog10(n)+1 ;
end if;
[op(convert(n, base, 10)), seq(0, i=1..dgs-ndgs)]
end proc:
digcatL2 := proc(L1, L2)
digcatL([op(L1), op(L2)]) ;
end proc:
A089754 := proc(n)
local prep, a, dgs ;
if isprime(n) then
n;
elif modp(n, 2) = 0 or modp(n, 5) = 0 then
ndgs := convert(n, base, 10) ;
for dgs from 1 do
for prep from 0 to 10^dgs-1 do
a := digcatL2(ListTools[Reverse](ndgs), ListTools[Reverse](nleadzero(prep, dgs))) ;
if isprime(a) then
return a;
end if;
end do:
end do:
else
for prep from 1 do
a := digcat2(prep, n) ;
if isprime(a) then
return a;
end if;
end do:
end if;
end proc: # R. J. Mathar, Sep 18 2015
CROSSREFS
KEYWORD
base,easy,nonn
AUTHOR
Amarnath Murthy, Nov 22 2003
EXTENSIONS
Corrected by R. J. Mathar, Sep 18 2015
STATUS
approved