Solution to problem 24