;!/usr/bin/racket
;#lang racket
(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)))))
(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)
OyEvdXNyL2Jpbi9yYWNrZXQKOyNsYW5nIHJhY2tldAoKKGRlZmluZSAoY29udC1mcmFjIG4gZCBrKQogICAgICAgIChkZWZpbmUgKGZyYWMgaSkKICAgICAgICAgICAgICAgIChpZiAoPCBpIGspCiAgICAgICAgICAgICAgICAgICAgICAgICgvIChuIGkpCiAgICAgICAgICAgICAgICAgICAgICAgICAgICgrIChkIGkpIChmcmFjICgrIGkgMSkpKSkKICAgICAgICAgICAgICAgICAgICAgICAgKC8gKG4gaSkgKGQgaSkpKSkKICAgICAgICAoZnJhYyAxKSkKCgooZGVmaW5lIChjb250LWZyYWMtaXRlciBudW1lbmF0b3IgZGVub21pbmF0b3IgaykKICAgICAgICAoZGVmaW5lIChpdGVyIGkgcmVzdWx0KQogICAgICAgICAgICAgICAgKGlmICg9IGkgMCkKICAgICAgICAgICAgICAgICAgICAgICAgcmVzdWx0CiAgICAgICAgICAgICAgICAgICAgICAgIChpdGVyICgtIGkgMSkKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAoLyAobnVtZXJhdG9yIGkpCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKCsgKGRlbm9taW5hdG9yIGkpCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJlc3VsdCkpKSkpCiAgICAgICAgKGl0ZXIgKC0gayAxKQogICAgICAgICAgICAgICAgICAgKC8gKG51bWVyYXRvciBrKQogICAgICAgICAgICAgICAgICAgICAgKGRlbm9taW5hdG9yIGspKSkpCgooZGlzcGxheSAoY29udC1mcmFjIChsYW1iZGEgKGkpIDEuMCkKICAgICAgICAgICAgICAgICAgICAobGFtYmRhIChpKSAxLjApCiAgICAgICAgICAgICAgICAgICAgIDEwMCkpCihuZXdsaW5lKQoKKGRpc3BsYXkgKGNvbnQtZnJhYy1pdGVyIChsYW1iZGEgKGkpIDEuMCkKICAgICAgICAgICAgICAgICAgICAgICAgIChsYW1iZGEgKGkpIDEuMCkKICAgICAgICAgICAgICAgICAgICAgICAgICAxMDApKQoobmV3bGluZSkK