首页 > 其他 > 详细

projecteuler---->problem=34----Digit factorials

时间:2015-08-21 09:20:47      阅读:202      评论:0      收藏:0      [点我收藏+]

Problem 34

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

原文:http://www.cnblogs.com/bhlsheji/p/4746802.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!