python 斐波纳契数列实现

 >>> # Fibonacci series: ...# the sum of two elements defines the next ...

 >>> a, b = 0, 1

 >>> while b < 10:

                  print(b)

        a, b = b, a+b

 

第一行,变量 a和b同時获得新的值0和1

在下面的也是同时获得,这样恰好满足了实现。

这样简单吧,继续学习中。

posted @ 2010-04-08 18:35  走到天亮  阅读(403)  评论(0编辑  收藏  举报