(define (cont-frac n d k)
(define (frac i)
(if (< i k)
(/ (n i)
(+ (d i) (frac (+ i 1))))
(/ (n i) (d i))))
(frac 1))
(define (cont-frac-iter numenator denominator k)
(define (iter i result)
(if (= i 0)
result
(iter (- i 1)
(/ (numerator i)
(+ (denominator i)
result)))))
(frac-iter (- k 1)
(/ (numerator k)
(denominator k))))
(display (cont-frac (lambda (i) 1.0)
(lambda (i) 1.0)
100))
(newline)
(display (cont-frac-iter (lambda (i) 1.0)
(lambda (i) 1.0)
100))
(newline)
CgooZGVmaW5lIChjb250LWZyYWMgbiBkIGspCiAgICAgICAgKGRlZmluZSAoZnJhYyBpKQogICAgICAgICAgICAgICAgKGlmICg8IGkgaykKICAgICAgICAgICAgICAgICAgICAgICAgKC8gKG4gaSkKICAgICAgICAgICAgICAgICAgICAgICAgICAgKCsgKGQgaSkgKGZyYWMgKCsgaSAxKSkpKQogICAgICAgICAgICAgICAgICAgICAgICAoLyAobiBpKSAoZCBpKSkpKQogICAgICAgIChmcmFjIDEpKQoKCihkZWZpbmUgKGNvbnQtZnJhYy1pdGVyIG51bWVuYXRvciBkZW5vbWluYXRvciBrKQogICAgICAgIChkZWZpbmUgKGl0ZXIgaSByZXN1bHQpCiAgICAgICAgICAgICAgICAoaWYgKD0gaSAwKQogICAgICAgICAgICAgICAgICAgICAgICByZXN1bHQKICAgICAgICAgICAgICAgICAgICAgICAgKGl0ZXIgKC0gaSAxKQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICgvIChudW1lcmF0b3IgaSkKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAoKyAoZGVub21pbmF0b3IgaSkKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVzdWx0KSkpKSkKICAgICAgICAoZnJhYy1pdGVyICgtIGsgMSkKICAgICAgICAgICAgICAgICAgICgvIChudW1lcmF0b3IgaykKICAgICAgICAgICAgICAgICAgICAgIChkZW5vbWluYXRvciBrKSkpKQoKKGRpc3BsYXkgKGNvbnQtZnJhYyAobGFtYmRhIChpKSAxLjApCiAgICAgICAgICAgICAgICAgICAgKGxhbWJkYSAoaSkgMS4wKQogICAgICAgICAgICAgICAgICAgICAxMDApKQoobmV3bGluZSkKCihkaXNwbGF5IChjb250LWZyYWMtaXRlciAobGFtYmRhIChpKSAxLjApCiAgICAgICAgICAgICAgICAgICAgICAgICAobGFtYmRhIChpKSAxLjApCiAgICAgICAgICAgICAgICAgICAgICAgICAgMTAwKSkKKG5ld2xpbmUpCg==