Solve problem 125 using Scala.