login
Largest n-digit prime in which the unit place digit is 1 and the k-th most significant digit is prime (2,3,5,7) if k is prime else is composite (4,6,8,9,0).
1

%I #5 Aug 13 2017 21:44:58

%S 71,751,9721,79531,978521,7979771,97979771,997979371,9997979371,

%T 79997979521,979997978551,7979997979571,97979997979771,

%U 997979997978571,9997979997978571,79997979997979731,979997979997978531

%N Largest n-digit prime in which the unit place digit is 1 and the k-th most significant digit is prime (2,3,5,7) if k is prime else is composite (4,6,8,9,0).

%e a(6) = 420221.

%p with(combinat, cartprod): ds:=proc(s) local j,l: l:=nops(s): RETURN(add(s[j]*10^(l-j),j=1..l)):end: p:=[7,5,3,2]:c:=[9,8,6,4,0]: cf:=[9,8,6,4]: ctpr:=proc(n,s) local m,T,a: a:=s: m:=1: T:=cartprod([seq(piecewise(isprime(n-i+2),p,i=2,cf,c),i=2..n),[1]]): while not T[finished] do m:=ds(T[nextvalue]()): if isprime(m) and not member(m,a) then a:=[op(a),m]: RETURN(a) fi od: end: a:=[]: for n from 2 to 22 do a:=ctpr(n,a) od: op(a); # C. Ronaldo

%Y Cf. A089704, A089705.

%K base,nonn

%O 2,1

%A _Amarnath Murthy_, Nov 10 2003

%E More terms from C. Ronaldo (aga_new_ac(AT)hotmail.com), Dec 25 2004