Added answer to problem 6 by haskell