%I #9 Nov 21 2013 12:50:05
%S 3,13,20,22,23,30,31,32,34,43,45,54,100,102,103,113,120,122,123,130,
%T 131,132,134,143,145,154,200,201,202,204,210,212,213,220,221,222,224,
%U 231,233,235,239,240,242,244,248,253,255,259,277,284
%N Numbers n such that the sum of subfactorial of the decimal digits of n is prime.
%C !k is a subfactorial number (A000166).
%H Harvey P. Dale, <a href="/A178712/b178712.txt">Table of n, a(n) for n = 1..1000</a>
%e 389 is in the sequence because !3 + !8 + !9 = 2 + 14833 + 133496 = 148331 is prime.
%p with(numtheory):f:=n->sum(n!*(((-1)^k)*1/k!),k=0..n):for n from 0 to 400 do:l:=length(n):n0:=n:s:=0:for m from 1 to l do:q:=n0:u:=irem(q, 10):v:=iquo(q, 10):n0:=v :s:=s+f(u): od: if
%p type(s,prime)=true then printf(`%d, `,n):else fi : od:
%t subf[n_]:=n!Sum[(-1)^k/k!,{k,0,n}]; Select[Range[300],PrimeQ[Total[ subf/@ IntegerDigits[#]]]&] (* _Harvey P. Dale_, Oct 03 2011 *)
%Y Cf. A000166.
%K nonn,base
%O 1,1
%A _Michel Lagneau_, Dec 26 2010
|