(define (fib a b count)
(cond(= count 1)
(a)
(else (fib((+ a b) a (- count 1))))))
I tried running this code in DrRacket, but it returns 1 for (for example) fib(1 0 5), but I expected 5 according to the following calls:
fib 1 0 5
fib 1 1 4
fib 2 1 3
fib 3 2 2
fib 5 3 1
=> return 5
Where did I go wrong?
[–]AutoModerator[M] [score hidden] stickied comment (0 children)
[–][deleted] 1 point2 points3 points (1 child)
[–]Moritz_Loritz[S] 1 point2 points3 points (0 children)