Solved problem 45 on PE