Solving Project Euler in Scala