From: Rohit Namjoshi Date: 2008-10-18T07:11:52+09:00 Subject: Re: Counting ------=_Part_76464_1415803.1224281552134 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline Using the fact that a multiple of 6 must be a multiple of 2 - apart from 2 and 4: (6..1000).inject(0) {|sum, i| i % 6 == 0 ? sum + i : sum} + 6 On Fri, Oct 17, 2008 at 4:44 PM, Tom Clarke wrote: > How would i go about making Ruby count to say 1000 usin only multiples > of say 2 and 6. Then i am looking to add all of the outputted numbers. > Can anyone help > -- > Posted via http://www.ruby-forum.com/. > > ------=_Part_76464_1415803.1224281552134--