145 is a curious number, as 1! + 4! + 5! = 1 + 24 + 120 = 145.
Find the sum of all numbers which are equal to the sum of the factorial of their digits.
Note: as 1! = 1 and 2! = 2 are not sums they are not included.
#factorial #Enumerable #dig_split #repeat_combos def p34 fax=(0..9).map{|i|factorial(i)} puts (2..7).map{|i|repeat_combos((0..9).to_a,i)}.inject{|u,v|u+v}. select{|a|a==dig_split(a.map{|i|fax[i]}.sum).sort}.map{|a|a.map{|i|fax[i]}.sum}.sum end