私信  •  关注

Babu Kanagaraj

Babu Kanagaraj 最近创建的主题
Babu Kanagaraj 最近回复了
5 年前
回复了 Babu Kanagaraj 创建的主题 » for循环内递归-Python

def recur_factorial(n, j=0):
j += 1
print('j=',j)
print('n=', n)    
if n == 1:
    return(1)
else:
    stop = n
    for i in range(2, stop + 1):
        print('i=', i)
        return n * recur_factorial(n = n - 1, j = j)
print('reached end of function') ##This statement will not execute since the function is returning before this statement