Exercise 5.01, naive recursive version