Recently I though that I need more practice in pure algorithms rather than in programming Android and Scala. I don’t know how much I will have time for this but I will try upload some exercises from Project Euler.

For today let’s start with first 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.

That can be simply done in Scala with one-liner:

1
2
3
object Euler01 {
  def multiplies() = (1 until 1000 toList).filter(i => i % 3 == 0 || i % 5 == 0).sum
}