Problem 20 (Project Euler) [和訳])
n! means n * (n - 1) * … * 3 * 2 * 1
Find the sum of the digits in the number 100!
n の階乗を返すメソッドを"fact(n)"と別途書いておいてから、下記の一行を実行すると答えが出ました。
puts fact(100).to_s.split(//).inject(0){|sum, i|sum += i.to_i}
このようにすんなりかけるようになってまいりました。だいぶ、Rubyに慣れた実感があります。