Skip to content

Instantly share code, notes, and snippets.

@yao2030
Created December 7, 2012 02:18
Show Gist options
  • Save yao2030/4230214 to your computer and use it in GitHub Desktop.
Save yao2030/4230214 to your computer and use it in GitHub Desktop.
(define (cont-frac n d k)
(define (cont-help i result)
(if (= i k)
(/ 1.0 result)
(cont-help (+ i 1) (/ (n i) (+ (d i) result)))))
(cont-help 1 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment