Problem 1-3 for "Ninety-Nine Scala Problems"