Solve SICP exercise 2.4