[archives] [homepage]

Problem 1.12
Friday, August 23, 2019; ago; Download .md

SICP Exercise 1.12

Add the values of the adjacent column elements in the row above.

(define (pascal-triangle row col) 
  (cond ((> col row) 0) 
        ((< col 0) 0) 
        ((= col 1) 1) 
        ((+ (pascal-triangle (- row 1) (- col 1)) 
            (pascal-triangle (- row 1) col)))))