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