A function that returns a list of the numbers of the Fibonac

2019-06-19 20:03栏目:技术创新
TAG:

def fib2(n): # return Fibonacci series up to n
     '''Return a list containing the Fibonacci series up to n.'''
     result = []
     a, b = 0, 1
     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

版权声明:本文由新浦京娱乐站_新浦京娱乐场官网_新浦京娱乐发布于技术创新,转载请注明出处:A function that returns a list of the numbers of the Fibonac