login
Least k made of identical digits such that the concatenation k, prime(n), k is prime. a(5) = 0.
3

%I #11 Jul 01 2021 12:13:30

%S 7,1,1,3,0,33,1,9,1,1,3,3,3,3,1,1,3,3,3,7,3,3,1,1111,111,3,3,1,9,1,33,

%T 1,111,3,1,3,3,9,777,1,3,77,7,9,1,777,9,3,7,333,7,1,3,1,3,3,3,3,9,7,3,

%U 3,3,3,9,1,9,777,7,3,3,1,77,9,11,1,3,9,1,9

%N Least k made of identical digits such that the concatenation k, prime(n), k is prime. a(5) = 0.

%p isA010785 := proc(n) convert(convert(n,base,10),set) ; if nops(%) = 1 then true ; else false ; fi ; end: A055642 := proc(n) ilog10(n)+ 1; end: A090269 := proc(n) local kern,k,p ; if n = 5 then RETURN(0) ; fi ; kern := ithprime(n) ; k := 1 ; while true do if isA010785(k) then p := k+10^A055642(k)*kern+k*10^(A055642(k)+A055642(kern)) ; if isprime(p) then RETURN(k) ; fi ; fi ; k := k+1 ; od ; end: seq(A090269(n),n=1..80); # _R. J. Mathar_, Jul 20 2007

%o (Python)

%o from sympy import prime, isprime

%o def a(n):

%o if n == 5: return 0

%o spn, digits = str(prime(n)), 1

%o while True:

%o for sk in [d*digits for d in "1379"]:

%o if isprime(int(sk + spn + sk)): return int(sk)

%o digits += 1

%o print([a(n) for n in range(1, 81)]) # _Michael S. Branicky_, Jul 01 2021

%Y Cf. A090268, A090266.

%K base,nonn

%O 1,1

%A _Amarnath Murthy_, Nov 28 2003

%E More terms from _R. J. Mathar_, Jul 20 2007