OFFSET
2,1
COMMENTS
See in the Prime Puzzle link the discussion for when n is a multiple of 6.
LINKS
Carlos Rivera, Puzzle 892. Primes as a concatenation of a series of powers of a prime, The Prime Puzzles and Problems Connection.
EXAMPLE
For n=2, the concatenation of 3^0 and 3^1 is 13 which is prime (while 12 was not prime); so a(2) = 3.
For n=3, the concatenation of 3^0, 3^1 and 3^2 is 139 which is prime (while 124 was not prime); so a(3) = 3.
MAPLE
g:= proc(p, n) local i, t;
t:= p^(n-1):
for i from n-2 to 0 by -1 do
t:= t + 10^(1+ilog10(t))*p^i
od;
t
end proc:
f:= proc(n)
local p;
if n mod 6 = 0 then return 0 fi;
p:= 3;
while not isprime(g(p, n)) do
p:= nextprime(p);
if n mod 3 = 0 then while p mod 3 = 1 do p:= nextprime(p) od fi:
od;
p
end proc:
map(f, [$2..30]); # Robert Israel, Sep 10 2017
PROG
(PARI) pconc(p, n) = {my(s = "1"); for (k=1, n, s = concat(s, Str(p^k)); ); eval(s); }
a(n) = {if (!(n % 6), return (0)); n --; my(p = 2); while (! isprime(pconc(p, n)), p = nextprime(p+1)); p; }
CROSSREFS
KEYWORD
nonn,base
AUTHOR
Michel Marcus, Sep 10 2017
EXTENSIONS
a(27)-a(50) from Robert Israel, Sep 10 2017
STATUS
approved