Added solution to problem 6 in C, Haskell, Java and Python