Hide
Solve a problem – Filter by language, license, keyword, owner, or search text to find code & info fast. Join Siafoo Now or Learn More

Fibonacci Sequence Generator

Revision 1 vs. Revision 2

Changelog: Added file name

Legend:

Unmodified
Added
Removed
  • Code

    r1 r2  
    1 """Fibonacci sequences using generators  
    2   
    3 This program is part of "Dive Into Python", a free Python book for  
    4 experienced programmers.  Visit http://diveintopython.org/ for the  
    5 latest version.  
    6 """  
    7   
    8 __author__ = "Mark Pilgrim (mark@diveintopython.org)"  
    9 __version__ = "$Revision: 1.2 $"  
    10 __date__ = "$Date: 2004/05/05 21:57:19 $"  
    11 __copyright__ = "Copyright (c) 2004 Mark Pilgrim"  
    12 __license__ = "Python"  
    13   
    14 def fibonacci(max):  
    15     a, b = 0, 1  
    16     while a < max:  
    17         yield a  
    18         a, b = b, a+b  
    19   
    20 for n in fibonacci(1000):  
    21     print n,  
    22   
     1"""Fibonacci sequences using generators 
    232 
     3This program is part of "Dive Into Python", a free Python book for 
     4experienced programmers.  Visit http://diveintopython.org/ for the 
     5latest version. 
     6""" 
     7 
     8__author__ = "Mark Pilgrim (mark@diveintopython.org)" 
     9__version__ = "$Revision: 1.2 $" 
     10__date__ = "$Date: 2004/05/05 21:57:19 $" 
     11__copyright__ = "Copyright (c) 2004 Mark Pilgrim" 
     12__license__ = "Python" 
     13 
     14def fibonacci(max): 
     15    a, b = 0, 1 
     16    while a < max: 
     17        yield a 
     18        a, b = b, a+b 
     19 
     20for n in fibonacci(1000): 
     21    print n, 
     22 
     23 
  • File Name

    r1 r2  
    1  
     1fibonacci.py