(define (tribo n) (if (< n 3) n (+ (tribo (- n 1)) (* 2 (tribo (- n 2))) (* 3 (tribo (- n 3)))))) ;Value: tribo
(tribo 20) ;Value: 10771211
(define (tribo2 n) (define (tribo-iter a b c count) (if (= count 0) a (tribo-iter b c (+ c (* 2 b) (* 3 a)) (- count 1)))) (tribo-iter 0 1 2 n)) ;Value: tribo2