Skip to content

Instantly share code, notes, and snippets.

@mohanrajendran
Created July 14, 2014 02:46
Show Gist options
  • Save mohanrajendran/07902d37efbb134d9c84 to your computer and use it in GitHub Desktop.
Save mohanrajendran/07902d37efbb134d9c84 to your computer and use it in GitHub Desktop.
SICP Exercise 1.12
;; Rows and columns start with index 1
(define (pascal row col)
(cond ((or (= col 1) (= col row)) 1)
(else (+ (pascal (- row 1) col) (pascal (- row 1) (- col 1))))))
;; Test cases
(pascal 1 1)
; 1
(pascal 13 7)
; 924
(pascal 13 6)
; 792
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment