Skip to content

Latest commit

 

History

History
20 lines (15 loc) · 320 Bytes

126.md

File metadata and controls

20 lines (15 loc) · 320 Bytes
@author jackzhenguo
@desc 
@date 2019/11/23

126 斐波那契数列前n项

def fibonacci(n):
    a, b = 1, 1
    for _ in range(n):
        yield a
        a, b = b, a + b


list(fibonacci(5))  # [1, 1, 2, 3, 5]
[上一个例子](125.md) [下一个例子](127.md)