login
Prime numbers n such that replacing each digit d in the decimal expansion of n with d^d produces a prime. Zeros are allowed with the convention 0^0 = 1.
1

%I #11 Sep 14 2017 03:53:31

%S 11,13,17,31,53,61,71,79,151,167,229,233,251,263,311,313,331,337,349,

%T 367,389,409,419,443,673,751,947,971,991,1433,1531,1699,1733,1993,

%U 2011,2027,2053,2063,2081,2111,2141,2153,2221,2333,2393,2503,2521,2833,2963

%N Prime numbers n such that replacing each digit d in the decimal expansion of n with d^d produces a prime. Zeros are allowed with the convention 0^0 = 1.

%e 263 is in the sequence because 263 becomes 44665627 which is also prime, where 44665627 is the concatenation of the numbers (2^2, 6^6, 3^3) = (4, 46656, 27).

%e 2503 is in the sequence because 2503 becomes 43125127 which is also prime, where 43125127 is the concatenation of the numbers (2^2, 5^5, 0^0, 3^3) = (4, 3125, 1, 27).

%p with(numtheory):T:=array(1..10):L:=array(1..10):

%p for n from 1 to 1000 do:

%p p:=ithprime(n):k:=0:s:=0:j:=0:

%p x:=convert(p,base,10):n1:=nops(x):

%p for m from n1 by -1 to 1 do:

%p k:=k+1:T[k]:=x[k]^x[k]:L[k]:=length(T[k]):

%p od:

%p n2:=sum('L[j]', 'j'=1..n1):s2:=0:

%p for u from n1 by -1 to 1 do:

%p s2:=s2+T[u]*10^(n2-L[u]):n2:=n2-L[u]:

%p od:

%p if type(s2,prime)=true

%p then

%p printf(`%d, `,p):

%p else

%p fi:

%p od:

%Y Cf. A068492, A240624.

%K nonn,base

%O 1,1

%A _Michel Lagneau_, Apr 09 2014