solve problem 47