f=->x{x<2?1:x*f[x-1]} gets $<.map{|l|d,x,t=l.split.map &:to_i puts t