Solution to problem 22