solve problem 2 in five languages