Created
December 7, 2012 02:23
-
-
Save yao2030/4230233 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
(define (cont-frac n d k) | |
(define (cont-help i result) | |
(if (= i 0) | |
result | |
(cont-help (- i 1) (/ (n i) (+ (d i) result))))) | |
(cont-help k 0.0)) | |
(cont-frac (lambda (i) 1.0) (lambda (i) 1.0) 100) | |
;; A so-called k-term finite continued fraction | |
;; gives the value of the gold ratio | |
(define (cont-fact n d k) | |
(define (cont-re i) | |
(if (> i k) | |
0 | |
(/ (n i) (+ (d i) (cont-re (+ i 1)))))) | |
(cont-re 1)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Exercise 1.38 sicp