Solve problem 35 using Scala.