Project Eulerで使ったメソッドをまとめてみました 特にProject Eulerやっている人には便利だと思うのでぜひ使ってみてください。 (コレを使ったらほとんど答えになるので、自分で正解出した後でこんなやり方もあるんだ程度で。。←ツッコミどころ満載です) require 'mathn' class Integer # 階乗 def fact (1..self).inject(:*) end # 約数 def divisor array = [] self.prime_division.each do |a| a[1].times do array.push(a[0]) end end d = [1, self] 1.upto(array.size - 1) do |n| array.combination(n).to_a.each do |c| d.push(c.inject