📜  python fibonacci 生成器 - Python 代码示例

📅  最后修改于: 2022-03-11 14:45:09.202000             🧑  作者: Mango

代码示例1
def fib(num):
    a = 0
    b = 1
    for i in range(num):
        yield a
        a, b = b, a + b # Adds values together then swaps them

for x in fib(100):
    print(x)