Solved problem 24 on PE