%I #7 Mar 30 2012 18:35:53
%S 0,11,0,0,0,102001,1000121,0,100012111,1000111121,10000000103,
%T 100000021211,1000000011103,10000000113011,100000000001203,
%U 1000000000021103,10000000001222111,100000000000002203,1000000000000122221
%N Smallest n-digit prime such that the sum of the square of digits equals n, or 0 if no such prime exists.
%e a(6) = 102001 because 1^2+0^2+2^2+0^2+0^2+1^2 = 6 = number of digits.
%p with(numtheory):Digits:=25:for k from 0 to 10 do: id:=0:for n from 10^k to
%p 10^(k+1)-1while(id=0) do:l:=length(n):n0:=n:s:=0:for m from 1 to l do:q:=n0:u:=irem(q,
%p 10):v:=iquo(q, 10):n0:=v :s:=s+u^2:od: if s=l and type(n,prime)=true then id:=1:print(n):else
%p fi:od:od:
%Y Cf. A073864
%K nonn,base
%O 1,2
%A _Michel Lagneau_, Jan 12 2011