Solve problems 16,20 using Scala.