标签:ruby projecteuler
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.
puts (0..50000).select{|i| i.to_s.length>1 && i == i.to_s.each_char.map{|d| (1..d.to_i).reduce(1,:*)}.reduce(:+)}.reduce(:+)
projecteuler---->problem=34----Digit factorials
标签:ruby projecteuler
原文地址:http://blog.csdn.net/q745401990/article/details/38816975