Project Euler #1

Add all the natural numbers below one thousand that are multiples of 3 or 5.

Besides the obvious solution by looping from 1 to 1000 and considering each number, this problem can be solved with some simple PIE counting.

Sum up all multiple of 3’s and 5’s with an arithmetic sequence, then subtract the multiple of 15’s due to overcounting.

Hopefully these type of posts will be much more interesting (for me too) as the questions get tougher.