Solution for prob 22