Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我会理解我的脚本对应的数学函数是什么:(x 必须是整数)
def f(x): if x==0: return -1 elif x==1: return -1 else: return f(x-1)*f(x-2)
递归函数 - 它是实现引用自身的函数。为了计算最终结果,它将使用不同的参数值调用它自己。
在您的情况下,没有递归
这不是递归函数, int 本身没有调用 int 。这只会计算 (x-1)*(x-2) ,除非 x 是 0 或 1。