Fibonacci: How to think recursively
Steven D'Aprano
steve at REMOVE-THIS-cybersource.com.au
Sun Aug 29 20:16:55 EDT 2010
On Sun, 29 Aug 2010 06:43:40 -0700, Baba wrote:
> So here's my code. It does still cause me one headache. If i use f(0)=0
> and f(1)=1 as base cases the result will be 144. I was expecting the
> result to be the next value in the series (233)...
That's because you're not generating the Fibonacci series, but a similar
unnamed(?) series with the same recurrence but different starting
conditions. The Fibinacci series starts with f(0)=1, f(1)=1.
> If i use f(1)=1 and
> f(2)=2 as base cases them i get my expected result.
Which implies that f(0) must be 1, not 0.
--
Steven
More information about the Python-list
mailing list