Euler project logo

Project Euler Problem 1 – Multiples of 3 and 5

I was randomly searching for best place to learn “programming by doing” and I have found link on Project Euler. I really like the idea of the project and I decided to join. Here is a description of the first Project Euler 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.

The problem is very easy. We are checking division of the numbers 3 and/or 5, the end number is not high and an idea of the sum is very clear. Despite the fact we need to brute-forcefully iterate all over the first 1000 numbers, I did not think much about any other complicated algorithm. The brute-force can be enough in this case.

PHP:

JAVA: