SICP exercises 1.2 cont. 2Posted: January 6, 2013
Again only one problem. I’ll need to be more motivated.
The following pattern of numbers is called Pascal’s triangle.
The numbers at the edge of the triangle are all 1, and each number inside the triangle is the sum of the two numbers above it.35 Write a procedure that computes elements of Pascal’s triangle by means of a recursive process.
(define (pascal row nth) (cond ((or (= nth row) (= nth 1)) 1) ((< nth 0) 0) (else (+ (pascal (- row 1) nth) (pascal (- row 1) (- nth 1))))))