f=(1,1,2,6,24,120,720,5040,40320,362880) p=[s for s in range(11,10000000) if sum(f[int(i)] for i in str(s))==s] print sum(p), p