(define (cont-frac n d k)
  (define (cont-frac-helper i)
    (if (> i k)
        0
        (/ (n i) (+ (d i) (cont-frac-helper (+ i 1))))))
  (cont-frac-helper 1))

(define (ln-cf k)
  (define (n k) 1.0)
  (define (d k) (if (= (remainder (+ k 1) 3) 0) (* (/ (+ k 1) 3) 2) 1))
  (cont-frac n d k))

(ln-cf 10)

(define (tan-cf x k)
  (define (n k) (if ( = k 1) x (* x x)))
  (define (d k) (- (* 2 k) 1))
  (cont-frac n d k))

(tan-cf 0 10)
환영합니다. DrRacket, 버전 5.0.2 [3m].
언어: R5RS [사용자정의]; memory limit: 256 MB.
0.7182817182817183
0
>
신고

티스토리 툴바