Problem023 in scala