From: "Eric I." Date: 2007-06-19T04:55:05+09:00 Subject: Re: Another Easy Beginner Question On Jun 18, 3:40 pm, "Gregory Brown" wrote: > Wouldn't it be: > > def fact(n); n > 1 ? n + fact(n-1) : 1; end > puts (1..12).inject(0) { |s,r| s + fact(r) } That certainly works, although I'm personally uncomfortable with the name of your recursive method; "fact" seems to imply factorial, which this is not. If you like inject, how about a pair of 'em: puts (1..12).inject(0) { |sum, day| sum + (1..day).inject { |day_sum, gifts| day_sum + gifts } } Eric ---- Are you interested in on-site Ruby training that uses well-designed, real-world, hands-on exercises? http://LearnRuby.com