Fibonacci series recursion error

harrismh777 harrismh777 at charter.net
Sat Apr 30 00:51:09 EDT 2011


===============begin======================
def fib(i=1):
     l=[]
     p=0
     a=1
     n=p+a
     for j in range(1,i+1):
         l.append(a)
         p=a
         a=n
         n=p+a
     return l

list=fib(7)
=======================end======================


... the above, if you want to return the list, not print...




More information about the Python-list mailing list