# -*- coding: utf-8 -*- # http://odz.sakura.ne.jp/projecteuler/index.php?cmd=read&page=Problem%2053 # # そのまま.. def fact(n) (1 .. n).reduce(:*) end def c(n, r) fact(n) / (fact(r) * fact(n - r)) end puts (1 .. 100).reduce {|count, n| count + (1 ... n).reduce {|count1, r| count1 + (c(n, r) > 1000000 ? 1 : 0) } }