From: Sammy Larbi Date: 2007-06-19T02:09:32+09:00 Subject: Re: Another Easy Beginner Question I'm not sure why you'd want to, but I suppose you could do something like: gifts=0 (1..12).each do |i| (1..i).each { |j| gifts += 1 } end puts gifts danielj wrote, On 6/18/2007 11:50 AM: > There is a song that goes like this: > > On the first day of Christmas, my true love sent to me a partridge > in a pear tree. > On the second day of Christmas, my true love sent to me two turtle > doves and a partridge in a pear tree. > ... > > If this goes on for the 12 days of Christmas. How many presents will > your true love send you over Christmas? > (Hint: You will need a loop inside another). > > I don't think you need a loop inside a loop.... Here is what I did: > > day = 0 > gifts = 0 > > 12.times do > day = day + 1 > gifts = gifts + day > end > > print gifts > > Does anyone know how you would do it with a loop inside a loop em>? > > > > >