Exercise 52 by Carl Ayers