On Thu, Jan 31, 2008 at 11:06:04PM -0500, Mark Schoonover wrote:
> Well, I think I'm just having a clueless moment... (fib 5) is returning 5,
> (fib 10) is returning 55. I would think the (fib n) would return the
> sequence.

from definition in SICP p37...

fib(0) = 0
fib(1) = 1
fib(2) = fib(1) + fib(0) = 1 + 0 = 1
fib(3) = fib(2) + fib(1) = 1 + 1 = 2
fib(4) = fib(3) + fib(2) = 2 + 1 = 3
fib(5) = fib(4) + fib(3) = 3 + 2 = 5

following this pattern...

fib(6) = 8
fib(7) = 13
fib(8) = 21
fib(9) = 34
fib(10) = 55

Looks like you are doing it right.  I'm not sure what the problem is.
What do you mean when you say (fib n) should "return the sequence" ?

Chris

-- 
[email protected]
http://www.kernel-panic.org/cgi-bin/mailman/listinfo/kplug-lpsg

Reply via email to