In a quest to better myself as a human being i’m trying to get into math at the moment. I haven’t taken it seriously since school and feel it’s a powerful tool in any programmers arsenal. Every week i’m going to post a question from http://projecteuler.net/ which will slowly get harder as time goes on. Here is the first question, it’s pretty easy, you can use whichever programming language you wish:
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.
I would be interested to see other peoples solutions, I’ve already solved this myself but i won’t post my answer written in Ruby just yet as it will ruin the fun. As an added bonus see how efficient you can make your script, mine is currently running in 0.004 seconds, happy coding.
Challenge accepted!
Edit: http://pastie.org/1369360
(Source: afrancois)
Discussion