Project Euler implementation in Scala