Skip to content

Instantly share code, notes, and snippets.

@enigmaticape
Created November 4, 2012 18:55
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 enigmaticape/4013070 to your computer and use it in GitHub Desktop.
Save enigmaticape/4013070 to your computer and use it in GitHub Desktop.
Iterative (tail recursive) Fibonacci in Scheme (a snippet from SICP)
(define (fib n)
(fib-iter 1 0 n))
(define (fib-iter a b count)
(if (= count 0)
b
(fib-iter (+ a b) a (- count 1))))
@tobisor
Copy link

tobisor commented Apr 3, 2017

HOLY M... thank you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment