#!ruby -n d=->n{n>9?d[n/10+n%10]:n} f=->n,k=1{(k..n).reduce(:*)||1} l= ~/$/ p d[l.times.reduce(0){|m,i|m+$_[i].hex*f[l-1,l-i]/f[i]}]if$.>1