Added answer to problem 1 by scala