Solution to SICP Exercise 1.10

Structure and Interpretation of Computer Programs

Solution to Exercise 1.10:
> (A 1 10)
1024
> (A 2 4)
65536
> (A 3 3)
65536

(f n) computes 2n.

(g n) computes 2n for n>0. For n=0, it is 0.

(h n) computes h(n) such that if n=0, h(0)=0; otherwise h(n)=2h(n-1).

%d bloggers like this: