11 lines
267 B
Scheme
11 lines
267 B
Scheme
#lang sicp
|
|
|
|
(define (cont-frac n d k)
|
|
(define (cf-acc n d k i)
|
|
(if (= k i)
|
|
(/ (n i) (d i))
|
|
(/ (n i) (+ (d i) (cf-acc n d k (+ i 1))))))
|
|
(cf-acc n d k 0))
|
|
|
|
; it takes exactly k = 10, for 1/phi to be estimated accurately up to the
|
|
; 4th decimal
|