Created
July 14, 2014 02:46
-
-
Save mohanrajendran/07902d37efbb134d9c84 to your computer and use it in GitHub Desktop.
SICP Exercise 1.12
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; 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