Project Euler Problem 20
問題
n! means n × (n − 1) × ... × 3 × 2 × 1 Find the sum of the digits in the number 100!
ソース
class Integer def fact return 1 if self.zero? self * (self - 1).fact end end puts 100.fact.to_s.scan(/./).map{|x| x.to_i}.inject(:+)
解答
648
感想
本当にRubyってせこい!
階乗のメソッド書いているけど、ほぼ1行プログラミング。。。