Skip to content

Instantly share code, notes, and snippets.

@lazywithclass
Created November 28, 2011 22:39
Show Gist options
  • Save lazywithclass/1402417 to your computer and use it in GitHub Desktop.
Save lazywithclass/1402417 to your computer and use it in GitHub Desktop.
Fibonacci tail recursion in Scheme
(define (fib n)
(define (iter a b count)
(if (<= count 0)
a
(iter b (+ a b) (- count 1))))
(iter 0 1 n))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment