Hi All,

I’m working on solving the first problem on ProjectEuler.net and I just

can’t seem to figure out why the following code doesn’t output the

correct answer. I’ve found other solutions, but I want to make mine

work rather than copy someone else’s. Any ideas?

Here’s the problem: If we list all the natural numbers below 10 that are

multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is

23.

Find the sum of all the multiples of 3 or 5 below 1000.

And my (wrong) solution:

c = 0

d = 0

c.step(999, 3) { |number| c += number }

d.step(999, 5) { |number| d += number }

puts (c + d)

Thanks,

Ryan