Solution to problem 24.  Fun one