Created
July 25, 2013 05:41
-
-
Save hhc0null/6077161 to your computer and use it in GitHub Desktop.
put tribonacci numbers out with the tail recursion algorithm.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; 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