Skip to content

Instantly share code, notes, and snippets.

@shirok
Created September 25, 2012 03:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shirok/3779859 to your computer and use it in GitHub Desktop.
Save shirok/3779859 to your computer and use it in GitHub Desktop.
(define (continued-fraction r)
(let loop ([p (numerator r)]
[q (denominator r)])
(receive (quot rem) (quotient&remainder p q)
(if (zero? rem)
(list quot)
(lcons quot (loop q rem))))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment