Problems 1-6 for the 'Scala99' challenge.