标签:斐波那契数列 bsp lis div int 斐波那契数 code color yield
def fib(n): a = 0 b = 1 num = 0 while num < n: yield(b) a,b = b,a+ b num += 1 fib = fib(20) print(list(fib)) #[1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597, 2584, 4181, 6765]
标签:斐波那契数列 bsp lis div int 斐波那契数 code color yield
原文地址:https://www.cnblogs.com/thanos-ryan/p/13339330.html