$<.map{|l|def calc(v) s=0 i=v while i>0 s+=i%10 i/=10 end a=[0] 2.upto(v){|i|if v%i==0 a << calc(v/i) end} s + a.max end p calc(l.to_i)} __END__ XXXXXXXXXXXXXX