Info

Hi, I'm David Askew

I build things

Homepage

Contact Me

About

Open Source

Project Euler - Problem 001

Spoiler Alert: Don’t read this any further if you are interested in learning this on your own. The solution is below.

You have been warned.

Having just finished the Rails Engineering course at the IronYard, I am looking for additional ways to strengthen my Ruby knowledge. Subsequently, I am working through some of the Project Euler problems. Below is the solution for Problem 001.

1
2
3
items = []
(1...1000).each { |num| items << num if num % 3 == 0 || num % 5 == 0 }
answer = items.reduce(:+)