Solved problem 47 in scala