python自定义函数演示,计算Fibonacci数列,pythonfibonacci,#-----------


#------------------------------------------------------------------------------#           Name: function.py#         Author: Kevin Harris#  Last Modified: 02/13/04#    Description: This Python script demonstrates how to create a function#                 that writes the Fibonacci series up to n.#------------------------------------------------------------------------------def fibonacci( n ):    a, b = 0, 1    while b < n:        print( b )        a, b = b, a+b# Now call the function we just defined...fibonacci( 2000 )input( '\n\nPress Enter to exit...' )
                                输出结果如下:
11235813213455891442333776109871597

评论关闭