login
a(n) is the least k such that the concatenations of k^i, i=0..j, are prime for j from 1 to n.
0

%I #18 Sep 09 2024 09:34:57

%S 1,3,22557,354081,419163,286623930087

%N a(n) is the least k such that the concatenations of k^i, i=0..j, are prime for j from 1 to n.

%C For n >= 2, a(n) == 3 (mod 6) if it exists.

%C a(6) > 3 * 10^9 if it exists.

%C No further terms < 10^11, testing all odd numbers (see Python program). - _Michael S. Branicky_, Sep 08 2024

%e a(3) = 22557: 22557^2 = 508818249, 22557^3 = 11477413242693, and the concatenations 122557, 122557508818249, and 12255750881824911477413242693 are all prime.

%p tcat:= (a,b) -> a*10^(1+ilog10(b))+b:

%p k:= 2: R:= 1:

%p for n from 2 to 5 do

%p for j from k by 6 do

%p c:= 1; good:= true;

%p for i from 1 to n while good do

%p c:= tcat(c, j^i);

%p if not isprime(c) then good:= false; break fi

%p od;

%p if good then k:= j; R:= R,j; break fi

%p od od:

%p R;

%o (Python)

%o from itertools import count

%o from gmpy2 import is_prime, mpz, digits

%o def f(k):

%o i, s = 0, "1"

%o while True:

%o ski = digits(k**(i+1))

%o if not is_prime(mpz(s+ski)):

%o break

%o i, s = i+1, s+ski

%o return i

%o def afind():

%o adict = dict()

%o for m in count(1, 2): # or count(3, 6) for a(2) on per comment

%o v = f(m)

%o if v > 0 and v not in adict:

%o adict[v] = m

%o print("FOUND", m, v)

%o afind() # _Michael S. Branicky_, Sep 08 2024

%Y Cf. A096469.

%K nonn,base,more

%O 1,2

%A _Robert Israel_, Sep 06 2024

%E a(6) from _Michael S. Branicky_, Sep 09 2024