A function that returns a list of the numbers of the Fibonacci series : Return List : List PYTHON examples


PYTHON examples » List » Return List »

 

A function that returns a list of the numbers of the Fibonacci series


A function that returns a list of the numbers of the Fibonacci series


def fib2(n): # return Fibonacci series up to n
     """Return a list containing the Fibonacci series up to n."""
     result = []
     a, b = 01
     while b < n:
         result.append(b)    # see below
         a, b = b, a+b
     return result
 
f100 = fib2(100)    # call it
print f100          # write the result


           
       



    Related Scripts with Example Source Code in same category :

Leave a Comment / Note


 
Verification is used to prevent unwanted posts (spam). .


PYTHON examples

 Navioo List
» Return List