#!/usr/bin/env python # -*- coding;utf-8 -*- """ 递归不能无限,python会限制递归深度,递归主要用于费布拉切数列 """ li = [] # 可以控制迭代深度的费布拉切数列 def foo(depth, a1, a2): if depth == 998: return a1 a3 = a1 + a2 r = foo(depth + 1, a2, a3) return r a = foo(1, 0, 1) print(a)