Solve SICP exercise 1.23