On Aug 24, 10:59 am, kangshu...@hotmail.com wrote:
> Now I have a problem and I holp someone can help me.
>
> def fib(x):
> if x==0 or x==1: return 1
> else: return fib(x-1) + fib(x-2)
This must be from "How not to program". Was this a personal pick or
recommendation?
--
http://mail.pyt
hi John
it's simple,
let's make a little modification for the scipt:
def fib(x):
if x==0 or x==1: return 1
else: return fib(x-1) + fib(x-2)
for i in range(10):
print 'fib(%s): ' % i, fib(i)
result:
fib(0): 1
fib(1): 1
fib(2): 2
fib(3): 3
fib(4): 5
fib(5): 8
fib(6): 13
fib(7):
In
kangshu...@hotmail.com writes:
> Hi everyone
> I just study python for a few time.
> Now I have a problem and I holp someone can help me.
> There is a piece of code:
> def fib(x):
> if x==0 or x==1: return 1
> else: return fib(x-1) + fib(x-2)
> Could you explain how it works?
> Tha
Hi everyone
I just study python for a few time.
Now I have a problem and I holp someone can help me.
There is a piece of code:
def fib(x):
if x==0 or x==1: return 1
else: return fib(x-1) + fib(x-2)
Could you explain how it works?
Thanks for you help.
Vince
--
http://mail.python.org/mai