From: Todd Benson Date: 2008-10-19T05:30:08+09:00 Subject: Re: Counting On Sat, Oct 18, 2008 at 10:02 AM, Craig Demyanovich wrote: > The OP needs multiples of 2 and 6. Since all multiples of 6 are also > multiples of 2, just checking for multiples of 6 suffices. However, if d = > 6, your two approaches don't produce the same result. For d = 6, they > produce 83498 and 83166, respectively. 83166 is the correct answer, I > believe. Well, I don't think he meant all multiples of (2 AND 6), or in this case (2 AND 5). That will always be simply always be multiples of the LCM, which, for (2 AND 6) is 6, for (12 AND 18) is 36, for (2 AND 5), 10, etc. lcm = 2.lcm 5 puts (1..1000/lcm).map.inject {|s, i| s + i * lcm} I think he meant (multiples of 2) AND (multiples of 6), or in this case (multiples of 2) AND (multiples of 5), which would be multiples of either. In that case check whether the number is cleanly divisible by number a and number b using %. Todd