Skip to content

Instantly share code, notes, and snippets.

@hhc0null
Created July 25, 2013 05:41
Show Gist options
  • Save hhc0null/6077161 to your computer and use it in GitHub Desktop.
Save hhc0null/6077161 to your computer and use it in GitHub Desktop.
put tribonacci numbers out with the tail recursion algorithm.
; put tribonacci numbers out with the tail recursion algorithm
(define (tribonacci n)
(tribo-tail n 0 0 1))
(define (tribo-tail n a b c)
(cond
((= n 0) or (= n 1) 0)
((= n 2) c)
(else
(let ((m (- n 1)))
(tribo-tail m b c (+ a b c))))))
(display (tribonacci 100000))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment