OFFSET
0,1
COMMENTS
!k is a subfactorial number (A000166).
a(148349)= 0 because the only number equal to the sum of subfactorials of its digits is :
148349 = !1 + !4 + !8 + !3 + !4 + !9.
EXAMPLE
a(0) = 2 because 0 -> 1->; 0 ;
a(1) = 1 because 1 -> 0 ;
a(2) = 2 because 2 -> 1-> 0 ;
a(3) = 3 because 3 -> 2 -> 1-> 0 ;
a(4) = 10 because 4 -> 9 -> 133496 -> 133774 -> 3721 -> 1857 ->
16731->2121->2 ->1->0.
MAPLE
with(numtheory): f:=n->sum(n!*(((-1)^k)*1/k!), k=0..n):for n from 1 to 150 do:it:=1:nn:=n:ind:=0:for iter from 1 to 50 do: l:=length(nn):n0:=nn: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: nn:=s:if nn<>0 then it:=it+1:else fi:od:printf(`%d, `, it):od:
MATHEMATICA
g[n_] := Plus @@ Subfactorial /@ IntegerDigits@ n; f[n_] := Length@ Sort@ NestWhileList[ g, n, # != 0 &, 1, 111] - 1; f[0] = 2; Array[f, 80, 0]
CROSSREFS
KEYWORD
nonn,base
AUTHOR
Michel Lagneau, Dec 23 2010
STATUS
approved